Programming Tutorials

PHP file upload prompts authentication for anonymous users

By: Phil Ciebiera in PHP Tutorials on 2012-12-05  

On a Microsoft platform utilizing IIS, you may run into a situation where, upon moving the uploaded file, anonymous web users can't access the content without being prompted to authenticate first...

The reason for this is, the uploaded file will inherit the permissions of the directory specified in the directive upload_tmp_dir of php.ini. If this directive isn't set, the default of C:\Windows\Temp is used.

You can work around this by granting the IUSR_[server name] user read access to your temporary upload directory, so that after you move_uploaded_file the permissions will already be set properly.

It's also a good idea to set the Execute Permissions of the upload directory to NOT include Executables, for security reasons.

To accomplish this:

  • Open the IIS Manager
  • Browse to the relevant sites directory where the uploads will be placed
  • Right Click the folder and select Properties
  • In the Directory tab of the resulting dialog, set the Execute permissions to be None

This took me a while to figure out, so I hope this helps save some other peoples time.

Add Comment

* Required information


No comments yet. Be the first!

Most Viewed Articles (in PHP )

Floating point precision in PHP

.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable

Installing PHP and MySQL in windows, mac and linux

PHP file upload prompts authentication for anonymous users

preg_match(), function preg_match_all(), preg_grep() in PHP

Installing PHP with Apache 2.x on HP UX 11i and configuring PHP with Oracle 9i

PHP INSTALLATION on Solaris 9 (Sparc)

Cannot load /usr/local/apache/libexec/ into server:

Setting up PHP in Windows 2003 Server IIS7, and WinXP 64

error: "Service Unavailable" after installing PHP to a Windows XP x64 Pro

Running different websites on different versions of PHP in Windows 2003 & IIS6 platform

Installing PHP with nginx-server under windows

Function to return number of digits of an integer in PHP

Function to sort array by elements and count of element in PHP

Function to force strict boolean values in PHP

Latest Articles (in PHP)