PHP: File uploads fail without any error

When handling uploads with PHP often it can happen, that the $_FILES array is simply empty. This can occur when one of the following things is true:

  1. 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.
  2. Make sure your FORM tag has the enctype=”multipart/form-data” attribute.
  3. Do not use javascript to disable your form file input field on form submission!
  4. Make sure your directory has read+write permissions set for the tmp and upload directories.
  5. Make sure your FORM tag has method=”POST”. GET requests do not support multipart/form-data uploads.
  6. Make sure your file destination and tmp/upload directories do not have spaces in them.
  7. Make sure all FORMs on your page have /FORM close tags.
  8. 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.
  9. Your /tmp folder is full

Hope this helps!

Published by

KB

I'm a student at TUM in Computer Science & Pizza eating. Passionate for SRE, beautiful Code and Club Mate.

Leave a Reply