Home Backend Development PHP Problem What should I do if the writing of the uploaded file in php fails?

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

Jul 19, 2021 am 10:00 AM
php

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!

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 admin@php.cn

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

CakePHP Project Configuration

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

CakePHP Date and Time

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

CakePHP File upload

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

CakePHP Routing

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

Discuss CakePHP

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

How To Set Up Visual Studio Code (VS Code) for PHP Development

CakePHP Quick Guide CakePHP Quick Guide Sep 10, 2024 pm 05:27 PM

CakePHP Quick Guide

See all articles