Starting from PHP 4.2.0, PHP will return a corresponding error code along with the file information array. This code can be found in the error field in the file array generated when the file is uploaded, that is, $_FILES['userfile']['error'].
UPLOAD_ERR_OK
The value is 0, no error occurs, and the file is uploaded successfully.
UPLOAD_ERR_INI_SIZE
The value is 1, and the uploaded file exceeds the limit of the upload_max_filesize option in php.ini.
UPLOAD_ERR_FORM_SIZE
The value is 2, and the size of the uploaded file exceeds the value specified by the MAX_FILE_SIZE option in the HTML form.
UPLOAD_ERR_PARTIAL
The value is 3, only part of the file is uploaded.
UPLOAD_ERR_NO_FILE
The value is 4, no file was uploaded.
UPLOAD_ERR_NO_TMP_DIR
The value is 6 and the temporary folder cannot be found. Introduced in PHP 4.3.10 and PHP 5.0.3.
UPLOAD_ERR_CANT_WRITE
The value is 7, file writing failed. Introduced in PHP 5.1.0.
Note:
The above values became PHP constants after PHP 4.3.0.