Explanation of error return values in PHP $ _ FILES

Source: Internet
Author: User
Tags php file upload
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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.