Working …
This value you provided is not a number. Please try again.
This value you provided is not an integer. Please try again.
The value entered is not a valid Vanderbilt Medical Record Number (i.e. 4- to 9-digit number, excluding leading zeros). Please try again.
The value you provided must be within the suggested range
The value you provided is outside the suggested range
This value is admissible, but you may wish to double check it.
The value entered must be a time value in the following format HH:MM within the range 00:00-23:59 (e.g., 04:32 or 23:19).
This field must be a 5 or 9 digit U.S. ZIP Code (like 94043). Please re-enter it now.
This field must be a 10 digit U.S. phone number (like 415 555 1212). Please re-enter it now.
This field must be a valid email address (like joe@user.com). Please re-enter it now.
The value you provided could not be validated because it does not follow the expected format. Please try again.
Required format:
REDCap Logo
Plugins, Hooks, & External Modules
Developer methods for
Plugins, Hooks, & External Modules
Hook functions

REDCap Developer Tools:
Documentation for Plugins, Hooks, & External Modules

REDCap Version 14.9.1
REDCap::getFile
(REDCap >= 13.1.0)
REDCap::getFile — Returns the file contents, file name, and mime-type of a file stored in the REDCap system.
Description
array REDCap::getFile ( string $doc_id] )
Returns an array containing the file contents, original file name, and mime-type of a file stored in the REDCap system by providing the file's doc_id number (the primary key from the redcap_edocs_metadata database table).
Parameters
$doc_id
The file's doc_id number from the redcap_edocs_metadata database table.
Return Values
Returns an array containing the file contents, original file name, and mime-type of the stored file, in which the first array value will be the mime-type, the second array value will be the original file name, and the third array element will be the file's entire contents (as a string). If an error occurs, FALSE will be returned.
Examples
Example #1:
This example illustrates how one might obtain the contents of a stored file and store it elsewhere on the web server.
// Obtain its doc_id from the File Repository or from the redcap_edocs_metadata database table
$doc_id = 227;

// Get the file's file name and contents
list ($mimeType, $docName, $fileContent) = REDCap::getFile($doc_id);

// Store a copy of the file elsewhere on the server
$new_file_name = "/var/local/folder/" . $docName;
file_put_contents($new_file_name, $fileContent);
REDCap 14.9.1 - © 2024 Vanderbilt University