Solved

Cannot Open file with php on IIS

Posted on 2008-11-02
8
1,277 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

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
 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

772 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