Hello KamyP
Basically you could use this example:
First you make sure you have the right Contact form you execute the code on:
The id is the id of your form, in this example 119
add_action( 'wpcf7_before_send_mail', 'save_application_form');
function save_application_form($cf7) {
if ($cf7->id==119){
// ADD YOUR CODE HERE
}
}
Then the file copy by itelf
add_action( 'wpcf7_before_send_mail', 'save_application_form');
function save_application_form($cf7) {
if ($cf7->id==119){
$values = $cf7->posted_data;
$uploadedFile = $values['file'];
$srcfileextrainfo = '/path/to/your/wpcf7_uploads/'.$uploadedextrainfoFile;
$dstfileextrainfo = '/path/to/your/destination/folder/'.$uploadedextrainfoFile;
copy($srcfileextrainfo, $dstfileextrainfo);
}
}
That way the file is copied to the temp folder. The wpcf7 uploads folder is usually found under “www/wp-content/uploads/sites/9/wpcf7_uploads” where 9 is the number of your site.
In the final form, before sending you do the same as above, only using the id of the last form and adding following:
$cf7->uploaded_files = array ( 'file' => 'path/to/your/file.ext');
Don’t forget to put the file variable (or whatever you name it to the attachments list in contact form 7 form config.
Contact Form 7 automatically deletes the files, so you don’t have to worry about leftover files
Hope this helps,.
Eric