12

I am trying to do this:

$fh = fopen("req2" , 'w')

and I get:

Warning: fopen(D:\inetpub\wwwroot\req2) [function.fopen]: failed to open stream: Permission denied in D:\inetpub\wwwroot\test.php on line 44 can't open file

I gave "Full Control" permissions to IIS in the wwwroot directory. I had also tried the absolute path: $_SERVER['DOCUMENT_ROOT']."\\req2"

but i still get the same error. I am running IIS 7 on Windows 7.

hoshiKuzu
  • 866
  • 1
  • 12
  • 30
  • Use [Process Monitor](http://live.sysinternals.com/procmon.exe) to see which user is actually trying to access the file. – Uwe Keim Feb 09 '12 at 12:32
  • 2
    thanks! solved. it was me who didn't have permissions to write :P – hoshiKuzu Feb 09 '12 at 13:43
  • Try giving full control to all users, if it works then revert back access control one by one and you'd see which user was creating issue – muzaffar Oct 29 '15 at 05:56
  • Please have a look onto [http://forums.iis.net/t/1167645.aspx](http://forums.iis.net/t/1167645.aspx) Also see this [http://www.addictivetips.com/windows-tips/windows-7-access-denied-permission-ownership/](http://www.addictivetips.com/windows-tips/windows-7-access-denied-permission-ownership/) – Milap Feb 09 '12 at 12:35

4 Answers4

12

In Windows, you need to give user, IUSR the permission.

Sohail Ahmed
  • 1,047
  • 1
  • 11
  • 27
2

This worked for me:

Right click folder --> Properties --> Security --> Edit --> allow Full Control --> apply --> do this for all, or just the correct user

xinthose
  • 3,213
  • 3
  • 40
  • 59
1

Also, if you run into this with downloaded code, make sure that you have "unblocked" it to run locally.

File encryption must also be disabled.

Beachhouse
  • 4,972
  • 3
  • 25
  • 39
0

Got this today on Windows 10 after I shared the wwwroot folder. Was working before that. Had to take the sharing off and reapply iis_iusr access permissions.

Peter Brand
  • 576
  • 6
  • 20