Support » Fixing WordPress » 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?

Viewing 2 replies - 1 through 2 (of 2 total)
  • hi, i have just come across this same problem trying to get the bp-my-home plugin to work.

    i haven’t got to the bottom of it yet. any ideas anyone?

    Can either one of you post a complete code sample from your project so we can duplicate your error and find a work around for it?


Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘File uploads and WP_Filesystem’ is closed to new replies.