When using PHP to upload files, we will use a program to listen to the file information sent by the browser, first, it will pass the $ _ FILES [fieldName] [$ _ FILES ['file'] ['error'] value
UPLOAD_ERR_ OK: 0 // normal, upload successful
UPLOAD_ERR_INI_SIZE: 1 // the size of the file to be uploaded exceeds the maximum size allowed by the server. set the value of the upload_max_filesize option in php. ini.
UPLOAD_ERR_FORM_SIZE: 2 // the size of the uploaded file exceeds the value specified by the MAX_FILE_SIZE option of the hidden domain in the HTML form.
UPLOAD_ERR_NO_TMP_DIR: 6 // The temporary folder is not found.
UPLOAD_ERR_CANT_WRITE: 7 // File write failure
UPLOAD_ERR_EXTENSION: 8 // php file Upload extension is not enabled
UPLOAD_ERR_PARTIAL: 3 // only part of the file is uploaded.
The code is as follows:
Switch ($ _ FILES [$ field] ['error']) {
Case 1:
// The file size exceeds the server space.
$ This-> setError ("The file is too large (server ).");
Break;
Case 2:
// The size of the file to be uploaded exceeds the browser limit
$ This-> setError ("The file is too large (form ).");
Break;
Case 3:
// Only part of the file is uploaded
$ This-> setError ("The file was only partially uploaded .");
Break;
Case 4:
// The file to be uploaded is not found.
$ This-> setError ("No file was uploaded .");
Break;
Case 5:
// The temporary folder on the server is lost.
$ This-> setError ("The servers temporary folder is missing .");
Break;
Case 6:
// An error occurred while writing the file to the temporary folder.
$ This-> setError ("Failed to write to the temporary folder .");
Break;
}