?
Solved

Cannot Open file with php on IIS

Posted on 2008-11-02
8
Medium Priority
?
1,295 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

 

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

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

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

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
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…
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.
Suggested Courses

771 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