Home  >  Article  >  Backend Development  >  What should I do if there is an error that the temporary file cannot be found when uploading in PHP?

What should I do if there is an error that the temporary file cannot be found when uploading in PHP?

藏色散人
藏色散人Original
2020-07-22 10:56:383084browse

Solution to the temporary file not found error in php upload: First open the "php.ini" file; then remove the semicolon in front of the "upload_tmp_dir" item; then add a good path at the end such as "C:/ windows/temp"; finally add the read and write permissions to the website anonymous access user group.

What should I do if there is an error that the temporary file cannot be found when uploading in PHP?

php upload cannot find the temporary folder (solution)

[Cannot find the temporary folder] This error prompt is customized. For example, a certain shop program will prompt this when uploading, and a CMS will prompt "You did not select the file to upload" when uploading. Each PHP system has different opinions, but in fact it is PHP. The error is caused by the temporary folder used not having write permissions. At this time, the error code value of $_FILES['XXX']['error'] is 6.

Recommended: "PHP Tutorial"

First you need to open the php.ini file and configure the PHP environment under IIS. The php.ini file is usually placed in %system% /windows, here we open php.ini and search for

 ;upload_tmp_dir =;upload_tmp_dir =

There is no path behind this, that is, we have not set a temporary folder. The strange thing is that php.ini on many Chinese servers does not set this item , are all normal, but not working on the English server.

Then set it yourself

Remove the (;) semicolon in front of the upload_tmp_dir item, and add the path after it, such as setting it to:

upload_tmp_dir ="C:/windows/temp"

Give directory C :/windows/temp adds read and write permissions to the website anonymous access user group.

Another thing to note here is that for the upper-level directory windows, the "list directory" permission of the users user must also be set, otherwise it will be invalid. I've been puzzled by this issue for a long time.

The above is the detailed content of What should I do if there is an error that the temporary file cannot be found when uploading in PHP?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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