I'm trying to get a file uploaded through a PHP script, but my $_FILES array is always empty? My $_POST data entry for the file HTML input element has the filename...Just no file is created on my local system.
I've verified write access to the temp folder and explicity set it. I've checked phpinfo() to make sure file uploads are enabled, and they are.
What could be preventing this? Would mod_rewrite cause anything?
Thanks!
When you have the proper enctype(<form method="post" enctype="multipart/form-data">
), then check the errno variable in $_FILES, there are various possible causes for a failure. Typical is MAX_FILE_SIZE being exceeded.
http://php.net/manual/en/features.file-upload.errors.php
Since PHP 4.2.0, PHP returns an appropriate error code along with the file array. The error code can be found in the error segment of the file array that is created during the file upload by PHP. In other words, the error might be found in $_FILES['userfile']['error'].
UPLOAD_ERR_OK Value: 0; There is no error, the file uploaded with success.
UPLOAD_ERR_INI_SIZE Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini.
UPLOAD_ERR_FORM_SIZE Value: 2; The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.
etc.