<<< Back to the TFU FAQ
19. Php upload messages: How to find them and what they mean.
When an uploads fails because of server limitations php does return an error which should help you to find the problem. Below you find a small description how to find the error message (often the hard part) and what they really mean.
How to find out which error occured:
- Enable the upload in the config of TFU: Set $enable_upload_debug = true; - in JFU you can do this on the config page.
- Upload a file that fails.
- Check the tfu.log file. There you see how far the upload goes. Important is the output of 3a. There the upload information of php is dumped. There you normally find the follwing results
- [error] => 0 : The file was uploaded to the server. Check the messages after this in the tfu.log. There is no direct error at the upload.
- [error] => [1-7]: Check the errors below. In the phperror.log of your server you normally get a detailed error message.
- An empty array: This means that the file information was not forwarded to the php script. If this is the case the error was only written to phperror.log
- Where is the phperror.log?
-> see howto 14 -> how to redirect the error log.
Now you should get as least the error number or error code why the error fails:
0 - UPLOAD_ERR_OK: There is no error, the file uploaded with success.
1 - UPLOAD_ERR_INI_SIZE: The uploaded file exceeds the upload_max_filesize directive in php.ini .
2 - UPLOAD_ERR_FORM_SIZE: The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.
3 - UPLOAD_ERR_PARTIAL: The uploaded file was only partially uploaded.
4 - UPLOAD_ERR_NO_FILE: No file was uploaded.
6 - UPLOAD_ERR_NO_TMP_DIR: Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.
7 - UPLOAD_ERR_CANT_WRITE: Failed to write file to disk. Introduced in PHP 5.1.0.
8 - UPLOAD_ERR_EXTENSION: A PHP extension stopped the file upload. PHP does not provide a way to ascertain which extension caused the file upload to stop; examining the list of loaded extensions with phpinfo() may help. Introduced in PHP 5.2.0.
And here a small description I found what this error mean:
Two of the PHP file upload errors involve a max file size, both of which occur when a user tries to upload a file with a greater size than that which you allow but occur for different reasons. The "UPLOAD_ERR_INI_SIZE" error, which has error value code one, happens when you specify a "upload_max_filesize" directive in a php.ini file. If you don't use this file, you may specify a max file size in an HTML form. If the user tries to upload too large a file here, PHP returns "UPLOAD_ERR_FORM_SIZE" with error value two. Please check howto 4 and 14 how to set this values.
When a user tries to upload a file and that upload fails, PHP returns one of two possible errors. The first, "UPLOAD_ERR_PARTIAL" with error value three, occurs if a file only gets partially uploaded. This may happen for several reasons, including Internet disconnection or the user canceling the upload. "UPLOAD_ERR_CANT_WRITE" with error value seven occurs when the Web form can't write the uploaded file to the server. This too may happen for several reasons, such as if a Web server doesn't have enough space in which to write the file. Please check if enough space is available in the upload_temp_dir and the real destination. Furthmore check the timeouts of your server. Please check howto 4 and 14 how to set this values.
No File or Folder
When a user tries to upload a file, but PHP doesn't receive anything, it returns "UPLOAD_ERR_NO_FILE" with error value four to indicate the problem. This may occur if a user accidentally clicks an "Upload" button before specifying which file he wants to upload. This error can not be caused by TFU but maybe my a firewall, proxy or anti virus software.
While a file uploads to a server, the file is saved to a temporary folder until it finishes uploading. If you don't correctly configure a temp folder path either through a php.ini file or your Web design tool, PHP might return "UPLOAD_ERR_NO_TMP_DIR" with error value six if this error occurs. See howto 14 how to set you individual temp upload folder or ask your hoster to fix this path.
Extensions are functions, classes and streams that PHP uses extensions to build upon its scripts, such as those that establish connections to MySQL or FTP protocols. Sometimes one of these extensions may cause a PHP file upload to fail, in which case PHP returns "UPLOAD_ERR_EXTENSION" with error value eight. However, PHP doesn't specify which extension causes the error, so to correct the problem you have to thoroughly test and debug your code.
PHP File Upload Error
PHP: Error Messages Explained