Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Issue with WP_Filesystem and file uploads WordPress

I posted my issue here on the forums, but I wanted to post it here to get an answer as well:

[[LINK href="http://wordpress.org/support/topic/file-uploads-and-wp_filesystem?replies=1"]]http://wordpress.org/support/topic/file-uploads-and-wp_filesystem?replies=1[[/LINK]]

Basically when WP_Filesystem uses the FTP method, it is resetting my $_FILES variable and I can no longer reference the temporary file location. It should also be noted that once WP_Filesystem has gotten its information, it reruns the method, so even storing the file for future reference (using move_file_upload for example) is no good because I will have no way to reference the uploaded and stored file (unless there is some way to do this).

Anyways I just wanted to get some ideas and a solution! :-)

Answers (2)

2011-12-10

yves vu answers:

You should add enctype="multipart/form-data" - attribute to form tag. I forgot it while using extending the standard user profile form in wordpress.


Thomas Griffin comments:

Yes, I have already added that to the form. The issue isn't the file upload itself. As long as WP_Filesystem can run any mode other than FTP, everything works fine. It's only when it has to run in FTP mode that that popup box to add credentials comes into play and resets my $_FILES variable.

2011-12-12

Francisco Javier Carazo Gil answers:

Hi Thomas,

I think that if you have saved FTP credentials in wp-config.php you won't have the problem.


define('FTP_HOST', 'ftp.example.org');
define('FTP_USER', 'username');
define('FTP_PASS', 'password');
define('FTP_SSL', true);
define(FTP_BASE','...');
define('FTP_CONTENT_DIR', '...');
define('FTP_PLUGIN_DIR', '...');