Solved

Cannot Open file with php on IIS

Posted on 2008-11-02
8
1,274 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

920 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

13 Experts available now in Live!

Get 1:1 Help Now