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!




RSS feed | Trackback URI

25 Comments - Leave a comment.

Roland wrote
on 2007-01-26 10:11:18

Is theres a way to set this permission through FTP?

fusion wrote
on 2007-01-26 18:54:32

Well I’m not sure you can do that…

 
 
masima wrote
on 2007-02-20 03:11:19

This entry was useful very much. Thank you.

from Japan.

 
dave wrote
on 2007-02-20 12:25:37

Does Not Work

 
Tim wrote
on 2007-03-15 08:24:00

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?

Tim wrote
on 2007-03-15 21:54:17

OMG … I was trying to create an invalid file name.

Always look for the simple explanation, eh? :-)

 
 
sameer wrote
on 2007-03-20 10:00:12

Very useful post. :)
Thanks!!

 
nino wrote
on 2007-03-26 11:34:56

Thanks alot

I am really happy to find the answer..

once again thank you so much

 
prabha wrote
on 2007-04-24 08:03:28

Hey..thx for this tip. It did work and got rid of the error!!

 
Feijão wrote
on 2007-04-25 09:18:09

Thkx!! It’s work’s for me ;)

 
wild_bill wrote
on 2007-04-27 22:12:50

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!

 
par_ten wrote
on 2007-05-10 07:49:13

Thank you very much.

 
par_ten Thailand wrote
on 2007-05-10 09:50:36

Thank you very much

 
Jon wrote
on 2007-06-07 14:25:10

Any suggestions for those of us on a shared windows hosting environment? Don’t have access to the server or IIS directly.

RedSun wrote
on 2007-06-22 10:20:51

You have to contact your hosting provider, he is the only one who can set it (not possible from your computer).

 
 
FetkaN wrote
on 2007-06-08 02:00:27

Thanks man !!!! you rule !!

 
Biko wrote
on 2007-07-10 06:05:56

Thank you so much for this tip man! Helped me a lot!

 
Sridhar wrote
on 2007-09-04 10:06:15

Thanks a lot.

 
John wrote
on 2007-09-11 19:28:20

I had an issue with file upload / write and this solved it. You probably saved me a lot of googling and head scratching.

 
metaljey wrote
on 2007-10-10 18:19:16

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.

 
Ulf Lunde wrote
on 2007-12-05 16:56:53 Subscribed to comments via email

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.

 
Demola wrote
on 2007-12-07 17:10:36

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

 
Adrienne wrote
on 2008-01-11 20:02:23

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.

 
Shamsul Akmal Ahmad wrote
on 2008-03-14 11:24:05

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.

 
stardog wrote
on 2008-06-20 16:25:26

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.

 
Name (required)
E-mail (required - never shown publicly)
URI
Subscribe to comments via email
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.