php file upload error code: first mark the form in the html; then add a hidden field in the form and in front of the file; finally predefine the variable [$_FILES] array.
php file upload error code:
Note:
1. When uploading a file, the form form in the html must be marked:
enctype='multipart/form-data'
2. There is a saying that it must be in the form form and add a hidden field in front of the file, such as:
<input type=hidden name='MAX_FILE_SIZE' value='value'>
File upload error code:
1. The predefined variable $_FILES
array has 5 contents:
$_FILES[' userfile']['name']——The original name of the client machine file
$_FILES['userfile']['type']——The MIME type of the file
$_FILES['userfile']['size']——The size of the uploaded file, in bytes
$_FILES['userfile ']['tmp_name'] - the temporary file name stored on the server after the file is uploaded
$_FILES['userfile']['error'] - and the file Upload related error codes
2. Among them, $_FILES['userfile']['error']
can have the following values and meanings:
0 - No errors occurred and the file was uploaded successfully. It’s not necessarily true that a file has been uploaded. It’s possible that you can check and find that the size is 0.
1 - The uploaded file exceeds the limit of the upload_max_filesize option in php.ini.
2 - The size of the uploaded file exceeds the value specified by the MAX_FILE_SIZE option in the HTML form.
#3——Only part of the file was uploaded.
#4——No files were uploaded. It means that the file field of the form has no content and is an empty string.
Related learning recommendations: php programming (video)
The above is the detailed content of php file then upload error code. For more information, please follow other related articles on the PHP Chinese website!