• Hello,

    I have updated to the latest CF7 version and now my “save on server” hack doesn’t work anymore. The file upload feature works as expected, a file is attached to an email. But in my case I like to have the file not to be deleted from the server

    I noticed modules/file.php has been rewritten, amongst other files.

    Anyway, in the past I just out commented
    //@unlink( $dir . $file );
    on line 346 in file.php

    Now with the latest file.php I have tried to out comment

    //wpcf7_rmdir_p( path_join( $dir, $file ) );
    on line 391 in file.php

    also I tried to outcomment line 172 in includes/submission.php
    //$this->remove_uploaded_files();/
    without any luck?

    What could be a solution to have the uploaded file stored in the upload folder

    Disclaimer: I am aware of the security risk by saving a file on the server as Takayuki. But in this case I have only trusted users and I am on localhost network.

    [EDIT] A nicer way would be a function hook where we copy the uploaded file to a specified destination before deleting. So I don’t have to alter the CF7 sourcecode

    https://www.ads-software.com/plugins/contact-form-7/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter DDT

    (@ddt)

    Ok I am almost a happy camper.

    Out commenting //$this->remove_uploaded_files(); did work.
    I am testing on a mac and I didn’t realise the WPCF7_UPLOADS_TMP_DIR should include the /Applications/XAMPP/xamppfiles/htdocs/

    define('WPCF7_UPLOADS_TMP_DIR','/Applications/XAMPP/xamppfiles/htdocs/mydomain.com/_site/wp-content/uploads/specials/2016');

    Now for my second questions how do I get rid of the unique named folder created???

    FOUND IT; by out commenting line 162 in file.php
    uploads_dir = wpcf7_maybe_add_random_dir( $uploads_dir );

    How do I prevent the multiple images? I only want to store the original file and not the other filename-…X…?

    DISCLAIMER: don’t follow my steps if your website has ‘open’ file upload

    I’m attempting the exact same thing as you, and we both stumbled across the same fixes! (Sure wish I found this thread earlier.) I seem to get 403 errors when trying to access the upload directory, though. Both in the default dir and in any new path I define. Originally I thought it could be solved by simple permissions, but even with those set to 777 as test for both the folder AND the file, I still get a 403! Any tips?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to save an uploaded file on the server with latest CF7?’ is closed to new replies.