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::copyFile
(REDCap >= 12.5.0)
REDCap::copyFile — Creates a new file in REDCap by copying a file already stored in the system.
Description
int REDCap::copyFile ( int $doc_id [, int $project_id] )
Creates a new file in REDCap by copying a file already stored in the system when provided with the doc_id of the original file from the redcap_edocs_metadata database table in the REDCap system. Returns the doc_id for the newly created file. The new file will be automatically stored using the defined file storage method in the system (e.g., WebDAV, S3, local). Note: The original file whose doc_id is provided as a parameter will *not* be deleted by this process.
Parameters
doc_id
The doc_id of the file to be copied, in which the doc_id comes from the redcap_edocs_metadata database table in REDCap.
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.
Return Values
Returns the doc_id from the redcap_edocs_metadata database table for the newly created file. If an error occurs, "0" will be returned.
Examples
Example #1:
This example illustrates how one might copy an existing file in a REDCap project.
$doc_id = 223;
$new_doc_id = REDCap::copyFile($doc_id, $project_id);
REDCap 14.9.1 - © 2024 Vanderbilt University