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! 








Is theres a way to set this permission through FTP?
Well I’m not sure you can do that…
This entry was useful very much. Thank you.
from Japan.
Does Not Work
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?
OMG … I was trying to create an invalid file name.
Always look for the simple explanation, eh?
Very useful post.
Thanks!!
Thanks alot
I am really happy to find the answer..
once again thank you so much
Hey..thx for this tip. It did work and got rid of the error!!
Thkx!! It’s work’s for me
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!
Thank you very much.
Thank you very much
Any suggestions for those of us on a shared windows hosting environment? Don’t have access to the server or IIS directly.
You have to contact your hosting provider, he is the only one who can set it (not possible from your computer).
Thanks man !!!! you rule !!
Thank you so much for this tip man! Helped me a lot!
Thanks a lot.
I had an issue with file upload / write and this solved it. You probably saved me a lot of googling and head scratching.
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.
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.
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
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.
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.
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.
Thank you
Everything worked fine! Thanks very much! It has prevented me of spending too much time on getting this problem solved!
[...] A blog post on with instructions for changing permissions on Windows 2003 or XP [...]
thanks dude i like it the way ur suggestion helped.
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.
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?
Thank you for your help!
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
The Drupal installer requires that you create a settings file as part of the installation process.
1. Copy the ./sites/default/default.settings.php file to ./sites/default/settings.php.
2. Change file permissions so that it is writable by the web server. If you are unsure how to grant file permissions, please consult the on-line handbook.
More details about installing Drupal are available in INSTALL.txt.
This is the error I got-can some one please help me to fix it!
Hey, Folks!I’m getting this error: Permission Denied.I use Windows Server 2003 / PHP 5 Isapi mode.anybody can help me?Please!Thanks
I failed in upload a picture and reason is: Warning: move_uploaded_file…failed to open stream: Permission denied in … under windowsXP.
I did following step:
1.check php.ini for safty_mode:is OFF.
2.check IIS access setting:write permission
3.check FTP access setting:write permission
but property of the folder is read only, then I did following:
>- 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.
but I found write access has been checked to defaultly deny and unchangable at deny side. And even if I uncheck read only property for the folder manually, but when I show property next, it is checked to read only again.
What is wrong for my upload setting? Please help me, Thanks!!
A great explanation there, another good tip would be to reset IIS after you’ve done this. To do that, type:
[Windows Key] + R (or Start->Run)
iisreset [Return]
Give it a moment to run an there you go!
great post man, thank you.
Thanks, this solved what I was beginning to think was not possible ha.
Thank you, really you’re a life savior
Wow!! Short post, saved me hours of work!