ThinkPHP3.2 An error occurred while uploading the local file to the server.

Source: Internet
Author: User
As the title says, after this problem occurs, I naturally go to the source code, cut off the output a little bit, and finally summarize the problem to "temporary files can be found, I didn't respond when I operated on the temporary files. "I didn't realize that this was a problem with the server access permission. I went online and found it. Later, I thought the apache environment configuration was different from the local environment, and I uninstalled it again.

As the title says, after this problem occurs, I naturally go to the source code, cut off the output a little bit, and finally summarize the problem to "temporary files can be found, I didn't respond when I operated on the temporary files. "I didn't realize that this was a problem with the server access permission. I went online and found it. Later, I thought the apache environment configuration was different from the local environment, and I uninstalled it again.

As the title says, after this problem occurs, I naturally go to the source code, cut off the output a little bit, and finally summarize the problem to "temporary files can be found, I didn't respond when I operated on the temporary files. "I didn't realize that this was a problem with the server access permission. I went online and found it. Later, I thought that the apache environment configuration was different from the local environment, and I uninstalled and reinstalled it. I compared it with a line of local configuration files, and it was still the same.

Then I found a breakthrough in a CSDN blog ThinkPhp upload Server Module loading failure summary, which contains the following sentence :.. \ Runtime \ Logs \ log file ", I read the log file on the server and found the following code:

: Open_basedir restriction in effect. File (/tmp) is not within the allowed path (s ):

I realized that the problem lies in the access permission of the tmp Temporary Folder. Then, I moved the tmp temporary file directory uploaded by the file to another disk and set the entire disk to be readable to everyone, the result still does not work. And Google search for the above Code, to get the correct results, the problem is in the configuration of virtual domain name http-vhosts.conf, If you search "php_admin_value open_basedir" will get a lot of answers, copy and add

Solution:
Add the temporary directory of the uploaded file to the end of php_admin_value open_basedir and it looks like this:

Linux
Php_admin_value open_basedir "usr/local/apache/htdocs/www:/tmp"

Windows

Php_admin_value open_basedir "d: \ wampserver \ tmp; e: \ tmp"

Limiting PHP script operations to web directories can prevent programmers from using the copy function to copy system files to web directories. Move_uploaded_file is not restricted by open_basedir, so you do not need to modify the upload_tmp_dir value in php. ini.

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.