Support » Plugin: Contact Form 7 » Change how file upload works

  • Resolved mozrelic


    If I understand Contact Form 7s’ documentation correctly, after a file is uploaded using a form, it is held temporarily, then deleted.

    This excerpt is from said documentation on

    “…At this point, Contact Form 7 attaches the file to the mail and sends it. After these procedures, Contact Form 7 then removes the file from the temporary folder.”

    Is it possible to keep Contact Form 7 from removing the uploaded file? If so, how do I go about modifying the plugin to do so. I assume /modules/file.php is responsible for how this function of CF7 is handled.

    Any help would be very much appreciated, and if I can provide useful information, please let me know.

Viewing 2 replies - 1 through 2 (of 2 total)
  • I would like to have my Contact form 7 function this way as well (saving the files submitted per the form vs. emailing, as I expect large files to be sent). Please let me know if you find the solution. Thanks.

    So, I have solved this. It is necessary to modify code in two different files in the plugin for this to work. However it must be noted that if you modify these files, and choose to update CF7 in the future, your changes will be lost and this functionaly will be lost, and you will probably have to repeat these steps.

    If @takayuki has a better solution for this, it would be great if he could post it.

    In the plugin file structure, look for modules/files.php

    Comment out line 346

    // @unlink( $dir . $file );

    The next file is includes/submission.php

    Comment out line 157
    // $this->remove_uploaded_files();

    And also lines starting at 278 to 282

    public function remove_uploaded_files() {
    		foreach ( (array) $this->uploaded_files as $name => $path ) {
    			@unlink( $path );

    If you are attempting to upload files larger than 2mb you will need to make appropriate changes to .htaccess and perhaps php.ini, aswell as in the CF7 file field, but this information can be found in other places and I will not address this here.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change how file upload works’ is closed to new replies.