[Plugin: Contact Form 7] Leave file upload on server.
-
Hello!
First, WPFC7 is a magnificent addition to the WP community. Now, onto my issue.
I have a file upload field that has been configured to allow video files to be uploaded/emailed. Much to my surprise, the files are not “left” on the server, they are actually deleted after they have been successfully emailed.
I found this default configuration odd, considering the nature of my uploads. First, most of my uploaded files will never make it through as attachments in email, because of their sheer size, therefore, keeping them on the server is crucial.
Second, the option to leave or delete is NOT an option controlled by the administrator via the WPCF7 administrative interface. I think in the next release, this should be an option.
Leave on server? Yes/No
I found the php strings that “cleans” up the files after they are successfully emailed. I commented the lines out to omit the cleanup function. Here it is:
function wpcf7_cleanup_upload_files() { $dir = trailingslashit( wpcf7_upload_tmp_dir() ); if ( ! is_dir( $dir ) ) return false; if ( ! is_readable( $dir ) ) return false; if ( ! is_writable( $dir ) ) return false; if ( $handle = @opendir( $dir ) ) { while ( false !== ( $file = readdir( $handle ) ) ) { if ( $file == "." || $file == ".." || $file == ".htaccess" ) continue; $stat = stat( $dir . $file ); if ( $stat['mtime'] + 60 < time() ) // 60 secs @unlink( $dir . $file ); } closedir( $handle ); } } if ( ! is_admin() && 'GET' == $_SERVER['REQUEST_METHOD'] ) wpcf7_cleanup_upload_files();
Even after commenting these lines out, the files are not be left behind on the server.
I have ensured that my “max upload” sizes and timeouts in my php.ini are sufficient. I have been testing with a file that is within parameter of my constraints.
I have not specified an upload folder in my settings -> media. I am simply leaving it at its default of wp-content/uploads. Furthermore, I have defined WPCF&_UPLOADS_TMP_DIR in my wp-config.php to wp-content/uploads/wpcf7_uploads
Lastly, my file permissions are all up to snuff, I currently have them wide open at 777.
I am receiving the email with the attachment, but I plan on disabling this feature once I am able to successfully upload the files to the wpcf7_uploads directory.
My error logs do not report any errors.
Any help is greatly appreciated.
- The topic ‘[Plugin: Contact Form 7] Leave file upload on server.’ is closed to new replies.