Solution to php files upload error: 1. Open the php.ini file; 2. Remove the semicolon in front of the "upload_tmp_dir" item and add the path after it as "upload_tmp_dir = "C:/windows" /temp""; 3. Set the value of the "upload_max_filesize" option limit.
The operating environment of this tutorial: Windows 7 system, PHP version 8.1, Dell G3 computer.
What should I do if there is an error in uploading php files?
php $_FILES upload failed error return value description
When uploading files with PHP, we will use a program to monitor the file information sent by the browser. First, it will pass $_FILES[ fieldName]['error'] to determine whether the status of the file to be uploaded is normal.
$_FILES[fieldName] ['error']==0 means everything is normal
$_FILES['file']['error'] value
UPLOAD_ERR_OK: 0 //正常,上传成功 UPLOAD_ERR_INI_SIZE: 1 //上传文件大小超过服务器允许上传的最大值,php.ini中设置upload_max_filesize选项限制的值 UPLOAD_ERR_FORM_SIZE: 2 //上传文件大小超过HTML表单中隐藏域MAX_FILE_SIZE选项指定的值 UPLOAD_ERR_NO_TMP_DIR: 6 //没有找不到临时文件夹 UPLOAD_ERR_CANT_WRITE: 7 //文件写入失败 UPLOAD_ERR_EXTENSION: 8 //php文件上传扩展没有打开 UPLOAD_ERR_PARTIAL: 3 //文件只有部分被上传
-- -------------------------------------------------- ------------------------------------------
error 6 Solution
First you need to open the php.ini file and search for upload_tmp_dir
Remove the (;) semicolon in front of the upload_tmp_dir item and add the path after it, such as Set to:
upload_tmp_dir ="C:/windows/temp"
Add the read and write permissions of the website anonymous access user group. One thing to note here is that the upper directory is windows, and you must also have users permission to list the directory, otherwise it will be invalid
No need to restart after modifying php.ini
Linux can modify Php.ini in two situations;
1. If you modify php.ini because of the PHP command line, no need Restart;
2. If php.ini is modified because of APACHE, you need to restart apache;
error 1 Solution
Upload file size Exceeding the maximum upload allowed by the server, set the upload_max_filesize option limit value in php.ini
Recommended study: "PHP Video Tutorial"
The above is the detailed content of What to do if there is an error in uploading php files. For more information, please follow other related articles on the PHP Chinese website!