Frustrating moment of the day:
A file upload form that’s been working for a long time, suddenly fails. No file uploads work on the entire apache installation. Checking the drive space in the /tmp folder, even though 85MB are left, freeing up space reveals that if there isn’t a lot of free space left for /tmp, the $_FILES array just goes empty without further explanation. No useful error messages, or anything.
Freeing up space for /tmp solves the problem effectively.
Update: Since so many commenters have posted other problems that cause similar effects, here is a quick summary of potential issues that you should check:
- Check php.ini for file_uploads = On, post_max_size, and upload_max_file_size. Make sure you’re editing the correct php.ini – use phpinfo() to verify your settings. Make sure you don’t mispell the directives as 8MB instead of the expected 8M!
- Make sure your FORM tag has the enctype="multipart/form-data" attribute. No other tag will work, it has to be your FORM tag. Double check that multipart/form-data is surrounded by STRAIGHT QUOTES, not smart quotes pasted in from Word OR from a website blog (WordPress converts straight quotes to angle quotes!). If you have multiple forms on the page, make sure they both have this attribute. Type them in manually, or try straight single quotes typed in manually.
- Make sure your directory has read+write permissions set for the tmp and upload directories.
- Make sure your FORM tag has method="POST". GET requests do not support multipart/form-data uploads.
- Make sure your file destination and tmp/upload directories do not have spaces in them.
- Make sure all FORMs on your page have /FORM close tags.
- Make sure your file input tag has a NAME attribute. An ID attribute is NOT sufficient! ID attributes are for use in the DOM, not for POST payloads.