Configuring Upload_tmp_dir in PHP.ini when uploading files to PHP

Source: Internet
Author: User

In the "PHP 5.3 Primer Classic" 9.6.3 Trial (P235), gave an example of uploading files, where the file format is a JPEG image (Image/jpeg). If the Upload_tmp_dir parameter in PHP.ini was not previously configured, an upload failure message will appear. See the code snippet below

if (isset($_files$_files["Photo"] ["error"] = = UPLOAD_ERR_OK)

If the condition in the judgment statement is true, continue. At this point, the $_files["photo" ["error"] value is 6,UPLOAD_ERR_OK value of 0 (indicates successful upload).

The meanings of the different values of $_files["Photo" ["error"] are listed below:

The temporary folder could not be found, which is generally configured for Upload_tim_dir in Php.int, or its value is misconfigured.

Online example generally recommended Upload_tim_dir = "C:\Windows\Temp", in fact, because of security/permissions and other reasons, will still error (6).

Therefore, the author modifies its path to other, such as Upload_tim_dir = "C:\temp", at which time the program can run normally. Some bloggers mentioned the need to add "write" permissions to the Users group/user of the "C:\temp" folder. While the author tests that it is possible to not modify, it may be related to the machine/OS environment.

Tips:upload_tim_dir = "C:\Windows\Temp" in the path string to replace "\" with "/" or the combination of the two has no effect. (PHP 7.1.6)

Configuring Upload_tmp_dir in PHP.ini when uploading files to PHP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.