IIS configuration PHP cannot upload file resolution

Source: Internet
Author: User
Tags configuration php file upload ini temporary file storage

According to the above description, I suspect that the problem is in the permissions configuration of IIS, the IUSR_MACHINE account does not write to the upload permission, so the permission to modify, the permissions under IIS, NTFS under the permissions are modified, but ultimately useless, look up the information on the network is not corresponding, To test the upload page, the process is:

SWF file calls save.php upload file---->swf file to rename the uploaded file---> name returned to the save.php---> Display the last name.

Now the problem stays with the SWF file renaming here, has not been to display the last name, and the SWF file does not participate in the upload process, You can only do the problem lookup in the save.php file, test in the file, the last name used by the variable is filename, and then insert the following statement to test:

echo "Filename=2008*****.gif";

The function of this sentence is to make the filename has a value, save.php can be normal display, the original statement of a sentence of the shielding test, all normal returned, but when the test to:
if (mailto:! @move_uploaded_file ($f [%22tmp_name], $dest _dir. '/'. $fileName)) header ("http/1.0 404 Not Found");
This sentence when the problem arises, can not upload, look up the context, has not found tmp_name variables, but see the meaning is to upload the file to a temporary file, and then move to the destination position, that this TMP position where? Is this location not writable to cause the file cannot be uploaded?

Find online information, found below PHP.ini 2 places on the upload configuration:
File_uploads = on here to set whether HTTP uploads are allowed, the default should be on
upload_tmp_dir= here set up the temporary location where the uploaded files are stored

The relevant information about these 2 places online is:
I try to set up file uploading under IIS 7 and PHP 5.

The problem is to set 2 variables in php.ini

File_uploads = ON//Here is the php.ini file, this place is set to ON

Upload_tmp_dir = "C:inetpubwwwrootuploads"//This path is the upload file you set up temporary storage path

For some reasons such directory name works,
But "upload_tmp" won ' t work.

The second problem is to set correct user rigths for upload folders where your try to save your file. I set my Upload folder rights for the ' workgroup/users ' for the full access. If you are experiment by yourselves if you are need execute access, for example.

My php.ini Upload_tmp_dir is commented, not enabled, but not set, but why Apache2 can be normal upload it? Is the problem really out here?

Solve:

Create a new folder to do temporary upload directory, according to the English instructions above to modify the corresponding 2 items in the php.ini, temporary upload directory Upload_tmp_dir set up Powertrain folder, the folder to give "IUSR_ computer name" User can write, restart IIS, Upload to try, the problem is really so solved.


The final analysis answer:

The above content is written in 09, but now July 2010 I added a server, and there is this problem, and again in accordance with the above solution to implement, in the process of operation is probably due to where the wrong, unexpectedly did not succeed, had to spare some time to study the specific reasons, The reasons for this problem are found as follows.
Unable to upload files, does not mean that all files can not upload, because one of my web site, Flash call Fwrite () biography, such as success, but call

The code is as follows Copy Code
@move_uploaded_file ($f ["Tmp_name"], $dest _dir. '/'. $fileName)

Such a function can still not be uploaded when the photo is passed.
After my analysis, the reason is that fwrite () is a binary file, and Move_uploaded_file () is a text file, and the Windows operating system is a description of the [Reference PHP manual Fwrite () function] that distinguishes the 2 files. This means that these 2 different files in the PHP environment when the upload of the temporary upload directory is different, because in the configuration of the IIS environment of PHP, set the temporary directory for e:tmp, set up the directory of IUSR users can write, binary files can upload, So I suspect that the directory is the location where binaries upload temporary files, so where is the temporary file storage location for Move_uploaded_file () text files? In fact, the above paragraph in English, Upload_tmp_dir set the path is, but my several servers, the value of this setting for each server is commented out of the "no value", why some servers can upload, and some servers can not upload it? This is back to the previous question I raised, why Apache2 can upload and IIS can not upload it?
This time I analyze the upload.php file again, analyze the code that causes the fault in detail as follows:

  code is as follows copy code

//check for file upload
    if (! $_files[' upload '. $num] [' name '] = = "] {
      if ($_files[' upload '. $num] [' Size '] < $max _size) { 
   1, echo "File Upload path:". $location. $_files[' upload '. $num] [' name '];
    2, echo "File temporary file name:". $_files[' upload '. $num] [' tmp_name '];
    3,     move_uploaded_file ($_files[' upload '. $num] [' tmp_name '], $location. $_ files[' upload '. $num [' name ']] or $event = "failure";
   } else {
     $event = "File too large!";
   }

The 2nd sentence in the normal code does not exist, in order to test the convenience I added, its main purpose is to test my php.ini did not set the value of the upload_dir_tmp, the uploaded file temporarily saved where, This test found that the default storage location was in the C:windowstemp directory when the php.ini upload_dir_tmp value was not configured. and the temporary file is stored as a. tmp suffix, and the file will be deleted immediately, so you will not be able to find the UPLOAD_DIR_TMP's default path if you want to modify the search function through the operating system files.

Since we found the upload_dir_tmp default path, then modify the C:windowstemp access, give IUSR_ user writable, restart the IIS Admin Service, upload files, finally succeeded. This is why I have multiple servers upload_dir_tmp values are empty when some can be transmitted, some of the reasons for not being transmitted.

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.