Permission Denied – PHP On IIS
Hello there,
Have you ever tried to upload a file with php on IIS? or maybe just copy or create a file on a certain folder? Well, I’ve been trying to do that for a while, but it was returning:
Warning: [function] - Permission denied in [my code].
On Windows Server 2003, it’s not an issue and the user can figure out the solution easily by opening the properties of the folder and working with the security tab which I’ll explain later on.
On the other hand, Windows XP users have that security tab hidden. I kept on unchecking the Read-Only, but it was rechecked automatically! The trick is to show the Security Tab in the properties window of the folder. Windows XP have this option hidden; to show it follow the following procedure:
- Open My Computer
- Tools > Folder Options
- Go to the View tab
- In the bottom of the list uncheck “Use simple file sharing (Recommended)”
Now you will have the security tab shown in the properties of every folder. Now, to give write access to PHP in order to fopen, copy or upload a file, follow this procedure:
- Right click on the folder where you want give write access
- Properties
- Go to the Security tab
- Select the Internet Guest Account ([username]/IUSR_[username])
- Allow the Write and Modify access. (You can give full permission)
- Then press Ok.
Your write access should be working by now. Happy coding!


I am Elie El Khoury, from Lebanon (Byblos), Woopra co-founder & CIO, Web & Software Developer, Designer, Guitarist, Mac user and the worst blogger on earth! 


January 26th, 2007 at 10:11 am
Is theres a way to set this permission through FTP?
January 26th, 2007 at 6:54 pm
Well I’m not sure you can do that…
February 20th, 2007 at 3:11 am
This entry was useful very much. Thank you.
from Japan.
February 20th, 2007 at 12:25 pm
Does Not Work
March 15th, 2007 at 8:24 am
Fusion,
I had such high hopes when I encountered your post. And although I did activate the Security tab in XP, and set the permissions for IUSR_… , still it does not work. I can read local files, but I can not touch them.
Any more tricks up your sleeve?
March 15th, 2007 at 9:54 pm
OMG … I was trying to create an invalid file name.
Always look for the simple explanation, eh?
March 20th, 2007 at 10:00 am
Very useful post.
Thanks!!
March 26th, 2007 at 11:34 am
Thanks alot
I am really happy to find the answer..
once again thank you so much
April 24th, 2007 at 8:03 am
Hey..thx for this tip. It did work and got rid of the error!!
April 25th, 2007 at 9:18 am
Thkx!! It’s work’s for me
April 27th, 2007 at 10:12 pm
Excellent post, I’ve been overusing MySql when I should have been using files just because I couldn’t figure this out . . . thanks so much!
May 10th, 2007 at 7:49 am
Thank you very much.
May 10th, 2007 at 9:50 am
Thank you very much
June 7th, 2007 at 2:25 pm
Any suggestions for those of us on a shared windows hosting environment? Don’t have access to the server or IIS directly.
June 8th, 2007 at 2:00 am
Thanks man !!!! you rule !!
June 22nd, 2007 at 10:20 am
You have to contact your hosting provider, he is the only one who can set it (not possible from your computer).
July 10th, 2007 at 6:05 am
Thank you so much for this tip man! Helped me a lot!
September 4th, 2007 at 10:06 am
Thanks a lot.
September 11th, 2007 at 7:28 pm
I had an issue with file upload / write and this solved it. You probably saved me a lot of googling and head scratching.
October 10th, 2007 at 6:19 pm
Thank you!
This is was the other bit of information I needed to get this to work.
Note: I also added the Authenticated Users with the same permission to the folder. Between setting both groups to the same permissions, I was able to get passed this error.
December 5th, 2007 at 4:56 pm
Thank you!
Just what I needed!
Except I had to check Write access for “All”
before it worked for my ASP.NET VS2005 application
when not running it in the debugger.
December 7th, 2007 at 5:10 pm
Like a pain reliever… all my codes got no probs but i kept gettn this stupid access denied error… this post is insightful… i saved this forum for future php problems… once thanks a lot
January 11th, 2008 at 8:02 pm
Hey, just thought I’d let everyone know about a fix I had to do on Windows XP / IIS to resolve this issue:
Not only did I need to give ISUR_ full control to the files in the project in question, I had to do this:
- Right-click on the root of the site (for me, that’s a subfolder in wwwroot) and access Properties
- Go to Security tab
- Select Internet Guest Account (\ISUR_)
- Click “Advanced” button
- Click the “Replace permission entries on all child objects with entries shown here that apply to child objects”
- Click OK
- Click OK to the popup warning that says something about how permissions will be replaced (it’s a long, hard to read warning)
That did it for me, but it could have been because I have been fooling around with permissions for a while and may have screwed something else up previously. But I thought I’d post it just in case it helps someone out there.
Caveat: This may not work on your machine, and could screw things up. I really don’t know.
March 14th, 2008 at 11:24 am
Thanks for this valuable tip. I’m having the problem of deleting an existing file. I use PHP5 on IIS5. Now the problem has gone. Thanks very much.
Kuala Lumpur.
June 20th, 2008 at 4:25 pm
For me, running XP PRO SP2, my Properties tab was a little different than described, but I finally got it to work.
1. Right-click, choose Properties.
2. Select “Sharing” tab.
3. In “Network sharing and security” section, Check the box “Share this folder on the network.”
4. Leave the default “Share name”.
5. Check the box “Allow network users to change my files.”
6. Click Apply, OK.
August 3rd, 2008 at 5:38 am
Thank you
November 28th, 2008 at 10:53 pm
Everything worked fine! Thanks very much! It has prevented me of spending too much time on getting this problem solved!
December 10th, 2008 at 8:20 am
[...] A blog post on with instructions for changing permissions on Windows 2003 or XP [...]
January 9th, 2009 at 6:44 am
thanks dude i like it the way ur suggestion helped.
April 14th, 2009 at 8:05 pm
Thank you so much for sharing this tip. I’ve spent half the day pulling my hair out as to why I kept getting Permission Denied and your solution fixed it within minutes. Many, many thanks.
April 24th, 2009 at 2:07 pm
Followed the instructions exactly only to find that in the “Folder options/view” list there is no option “Use simple file sharing (Recommended)”
The last option in the list is “Show pop-up description…”
In another instruction it was said that I should press the key “advanced”, but there is no such key in the view window.
I have WinXP sp2
So I am stuck.
What to do?
April 27th, 2009 at 11:17 pm
Thank you for your help!
June 26th, 2009 at 1:15 am
Hi all,
I lost 1 day working on problem with write permissions on IIS and PHP. I have read number of manuals and make call to other administrators with question for help. I’m 100% sure I did everything right but my test show I have no write permission in target folder via PHP.
Here is the test code:
and error:
PHP Warning: fopen(/test.txt) [function.fopen]: failed to open stream: Permission denied in C:\Inetpub\wwwroot\WriteTest\WriteTest.php on line 5
line 5 says:
$testFile = fopen($absUploadFilderPath . ‘/test.txt’, “wt”);
This error message appear if there is no Uploads folder at all, or there is mistake in relative path (what is same – folder is missing )
Lesson is test your tests twice and don’t believe 100% on error messages.
With hope this will save someone headache
Regards, Greg