How to understand the error return value in PHP $_ FILES
This article focuses on "how to understand the error return value in PHP $_ FILES". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn "how to understand the error return value in PHP $_ FILES"!
$_ FILES ['file'] [' error'] value
UPLOAD_ERR_OK: 0 / / normal, uploaded successfully
UPLOAD_ERR_INI_SIZE: 1 / / the uploaded file size exceeds the maximum allowed for uploading by the server, and the upload_max_filesize option limit is set in php.ini.
UPLOAD_ERR_FORM_SIZE: 2 / / upload file size exceeds the value specified by the hidden field MAX_FILE_SIZE option in the HTML form
UPLOAD_ERR_NO_TMP_DIR: 6 / / No temporary folder cannot be found
UPLOAD_ERR_CANT_WRITE: 7 / / File write failed
UPLOAD_ERR_EXTENSION: 8 / / the php file upload extension is not open
UPLOAD_ERR_PARTIAL: 3 / / only part of the file is uploaded
The copy code is as follows:
Switch ($_ FILES [$field] ['error']) {
Case 1:
/ / the file size exceeds the space size of the server
This- > setError ("The file is too large (server).")
Break
Case 2:
/ / the file size 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:
/ / No file was found to upload
$this- > setError ("No file was uploaded.")
Break
Case 5:
/ / the server temporary folder is missing
$this- > setError ("The servers temporary folder is missing.")
Break
Case 6:
/ / error writing file to temporary folder
$this- > setError ("Failed to write to the temporary folder.")
Break
}
At this point, I believe you have a deeper understanding of "how to understand the error return value in PHP $_ FILES". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!