Solved

Cannot Open file with php on IIS

Posted on 2008-11-02
8
1,269 Views
Last Modified: 2013-12-13
Hi,

I' m getting the listed error when I try to update a text file or html file with php on my local IIS Server. I have set the folder and subfolder permissions to read and write from the IIS configuration panel.

The authentication is set to anonymous access and user name is iusr_computername.

Execute permissions is set to: Scripts and Executables.

Below is the PHP code I'm using.

Thanks.
<?
 

$stringData = stripslashes( $_POST['FCKeditor1'] ) ;

$myFile = "testFile.html";

$fh = fopen($myFile, 'w') or die("can't open file");

fwrite($fh, $stringData);

fclose($fh);
 

echo 'done';

?>

Open in new window

0
Comment
Question by:Rassac
  • 5
  • 3
8 Comments
 
LVL 6

Expert Comment

by:matjm
ID: 22860984
Hi there,

I suggest checking whether the php.ini file has read access by the IUSR account.
0
 

Author Comment

by:Rassac
ID: 22861057
How do I check that please since the php.ini is not listed with the website in the IIS config panel? My php file is stored in c:\windows.

0
 
LVL 6

Expert Comment

by:matjm
ID: 22861080
Generally you should put all of the PHP files, including the php.ini file in a different directory, for example C:\PHP and then add the IUSR account to have read access of that folder.

Give that a go and restart IIS before testing again.
0
 

Author Comment

by:Rassac
ID: 22861116
I have the php files in C:\PHP and the php.ini under c:\windows, however my question was, how could I give the IUSR account access on these files? Normally I go in the IIS config panel and right click on a website folder and set permissions from there. However the php.ini won't be listed in the Config Panel since it is not saved under c:\inetpub\wwwroot.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 6

Expert Comment

by:matjm
ID: 22861123
Sorry, I see what you're asking.

Just use Windows Explorer to set the permissions. Right click on the C:\PHP folder, go to Properties, and on the Security tab, ensure that the IUSR account is listed there and has read access. If it doesn't, then add it.

Repeat this on the php.ini file.
0
 

Author Comment

by:Rassac
ID: 22861179
I have no security tabs. Attached is a screen shot of my properties.
screencapture.jpg
0
 

Author Comment

by:Rassac
ID: 22900030
Hi,

Ok I managed to find the security Tab. I had the security tabs disabled from the folder tools. I have given the IUSR rights on wwwroot and php file as per attached. I have also restarted the IIS Server but still no go. :( See attached.


screencapture2.jpg
0
 

Accepted Solution

by:
Rassac earned 0 total points
ID: 22900087
ooppss... sorry.
Worked fine. had a small script problem this time!

Here are the steps performed found on http://www.php.net/manual/en/install.windows.iis.php:

   1. Did you disable Simple File Sharing? From any folder click Tools -> Folder Options -> View (tab)-> (scroll the list and find "Simple File Sharing (reccomended)") UNTICK IT
   2. Locate your localhost root directory, usually C:\InetPub\wwwroot\
   3. Open the Properties of the whole directory, in our case wwwroot
   4. Click the Protection tab(where to manage user rights)
   5. Click Add and then click Advanced (button in the bottom-left part of the window)
   6. Click Find (the only enabled button between Columns and Stop)
   7. Pick the user that starts with IUSR_ (which is the IIS default user) from the list Windows has kindly found for you
   8. push OK twice
   9. the new added IUSR_ will be selected, from the Authorizations list check Edit (to allow file creation/deletion) and Write (to allow file modify)
  10. click OK one more time to get back to your native folder
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now