Detailed explanation of error reporting when implementing file upload and download in PHP
Cause of error
Basically it exceeds or does not meet the server’s configuration for uploading files. So what are the server-side configurations?
First consider uploading what we used? POST, upload
So look for these items in php.ini:
file_upload:On
upload_tmp_dir=— —Temporary file storage directory;
upload_max_filesize=2M
max_file_uploads=20——The maximum number of files allowed to be uploaded at one time
post_max_size=8M——The maximum value of data sent in post mode
Other related configurations
max_exectuion_time=-1 ——Maximum execution time to prevent the program from occupying server resources;
max_input_time=60
max_input_nesting_level=64——Input nesting depth ;
memory_limit=128M - the maximum independent memory usage of a single thread
In short, it is all related to the configuration of resources
Error number
- ##UPLOAD_ERR_OK Value: 0; No errors occurred and the file uploaded successfully.
- UPLOAD_ERR_INI_SIZE Value: 1; The uploaded file exceeds the limit of the upload_max_filesize option in php.ini.
- UPLOAD_ERR_FORM_SIZE Value: 2; The size of the uploaded file exceeds the value specified by the MAX_FILE_SIZE option in the HTML form.
- UPLOAD_ERR_PARTIAL Value: 3; Only part of the file is uploaded.
- UPLOAD_ERR_NO_FILE Value: 4; No file was uploaded.
Note: This error message is the information uploaded in the first step, that is, when uploading to a temporary folder, not when moving or copying.