What should I do if the writing of the uploaded file in php fails?

藏色散人
Release: 2023-03-11 17:18:02
Original
2665 people have browsed it

php failed to write the uploaded file because the temporary folder space of the uploaded file was insufficient and the memory was insufficient. The solution was to open php.ini and set upload_tmp_dir and other items.

What should I do if the writing of the uploaded file in php fails?

The operating environment of this article: Windows 7 system, PHP version 7.1, DELL G3 computer

php What should I do if the uploaded file fails to be written? ?

PHP failed to write the uploaded file, error code 7

Problem upload service written by php, error reported after uploading the file:

Exception: 7!

Analysis of printing errors when uploading files in PHP

Generally when using FILES to upload files, you can use _FILES["file"]["error"] To determine whether there is an error in file upload.

UPLOAD_ERR_OK

The value is 0, no error occurs, and the file is uploaded successfully.

UPLOAD_ERR_INI_SIZE

The value is 1, and the uploaded file exceeds the limit of the upload_max_filesize option in php.ini.

UPLOAD_ERR_FORM_SIZE

The value is 2, and the size of the uploaded file exceeds the value specified by the MAX_FILE_SIZE option in the HTML form.

UPLOAD_ERR_PARTIAL

The value is 3, and only part of the file is uploaded.

UPLOAD_ERR_NO_FILE

The value is 4 and no file was uploaded.

UPLOAD_ERR_NO_TMP_DIR

The value is 6 and the temporary folder cannot be found. Introduced in PHP 4.3.10 and PHP 5.0.3.

UPLOAD_ERR_CANT_WRITE

The value is 7, file writing failed. Introduced in PHP 5.1.0.

[Solution]:

After searching for the reason, it was found that the temporary folder space for uploading files is not enough, that is, php.ini does not set upload_tmp_dir, upload_tmp_dir = no value, default The PHP process will read and write the system's temporary file directory:

* Windows : C:/windows/temp
* Linux : /tmp
Copy after login

Modify the upload_tmp_dir folder path, ensure that the folder has enough space, and grant read and write permissions.

Allocate more storage space to the default temporary file directory.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What should I do if the writing of the uploaded file in php fails?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!