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::storeFile
(REDCap >= 12.5.0)
REDCap::storeFile — Stores a file in REDCap when provided with the full path of a file on the local REDCap web server, in which the file will be automatically stored using the defined file storage method in the system (e.g., WebDAV, S3, local).
Description
int REDCap::storeFile ( string $filepath [, int $project_id [, string $name] )
Stores a file in REDCap when provided with the full path of a file on the local REDCap web server. Returns the doc_id from the redcap_edocs_metadata database table for the stored file. The file will be automatically stored using the defined file storage method in the system (e.g., WebDAV, S3, local). Note: The original file on the server will *not* be deleted by this process.
Parameters
filepath
The full file path of the file on the local REDCap web server.
project_id (optional)
The project ID number of the REDCap project with which you want to associate this file. If omitted or passed as NULL, the file will not be associated with a project.
name (optional; added in REDCap 13.11.3)
The file name. If not specified, this will be extracted from the file path. Use this to assign a filename to files that have a temporary filename, such as when resulting from a file upload.
Return Values
Returns the doc_id from the redcap_edocs_metadata database table for the stored file. If an error occurs, "0" will be returned.
Examples
Example #1:
This example illustrates how one might store a local file and associate it with a specific REDCap project.
// Store a file and obtain its doc_id from the redcap_edocs_metadata database table
$filepath = "/var/www/redcap/myfiles/studyfile003.docx";
$doc_id = REDCap::storeFile($filepath, $project_id);
REDCap 14.9.1 - © 2024 Vanderbilt University