• Resolved charliecammack

    (@charliecammack)


    Hi All,

    I’m using contact form 7 as a way of uploading files from the form directly to the drop box.

    I’ve read that contact form 7 stores the temporary files inside “wp-content/uploads/wpcf7_uploads” on form success and then deletes them straight after the form request is done. This is all working and I can see it happening when I post a form. However…

    I was expecting the file to go directly inside the “wpcf7_uploads” folder where I could then access the file just before it gets removed, this is not the case. Instead, contact form 7 creates a folder inside the “wpcf7_uploads” with what appears to be a random name, stores the upload in there and then removes it. I managed the capture one of these folders names temporarily and it was just a random series of numbers.

    Does anyone know how contact form 7 creates this folder, and how do I access it. I’ve tried dumping out the entire form submission by doing:

        $submission = WPCF7_Submission::get_instance();
      
        if ( $submission ) {
        	$posted_data = $submission->get_posted_data();
        }
    

    but it does not reference the folder name being creates anywhere. In an ideal world, i want to stop this additional level deep folder being created so I can access the temporary uploads then send them to dropbox. Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    You can access uploaded files with

    $uploaded_files = $submission->uploaded_files();

    Thread Starter charliecammack

    (@charliecammack)

    Brilliant thanks, this gave me exactly what I wanted. Although the path it returned contained a ‘//’ but a str_replace fixed this.

    I also want to now allow multiple file uploads on a single input field. Can this be achieve with CF7 out of the box?

    Thanks.

    cubanjaco

    (@cubanjaco)

    Hello, I’m trying to get uploaded files from mi functions.php file on this way:

    
    add_action('wpcf7_mail_sent', 'save_application_form' );
    
    function save_application_form($wpcf7) {
        $submission = WPCF7_Submission::get_instance();
        $files = $submission->uploaded_files();
    }
    

    But $files array are always empty.

    I also tried with wpcf7_before_send_mail action.

    What can be wrong?

    • This reply was modified 6 years ago by cubanjaco.
    • This reply was modified 6 years ago by cubanjaco. Reason: More explain question

    Takayuki,
    is there a code snippet or other method that would allow us to save the uploaded file into our website default media library?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Contact form 7 file upload creates random folder and stores uploads inside that.’ is closed to new replies.