File uploads and WP_Filesystem
-
So I’m having an issue with handling file uploads and using WP_Filesystem. I’ve got a form where a user can upload a zip file. Once they submit the form, I do the checks to make sure the file is a zip file and die if it is not.
Once security checks have been passed, then I setup WP_Filesystem. I then proceed to use
unzip_file
on the temporary file location and then use$wp_filesystem->get_contents()
and$wp_filesystem->put_contents()
respectively to put file(s) where they need to go.Here’s the problem – if WP_Filesystem cannot use the direct methods, then it uses FTP. This requires the user to submit their FTP information and then click ‘Proceed’. However, doing this empties out the $_FILES variable and I am left with no uploaded file to work with.
So how do I get around this? I know I can pass $extra_fields through
request_filesystem_credentials
, but I don’t think that will help with saving the uploaded file. How can I save that file and continue to handle and process it even if the user has to enter in their FTP information?
- The topic ‘File uploads and WP_Filesystem’ is closed to new replies.