Solved

Cannot Open file with php on IIS

Posted on 2008-11-02
8
1,290 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

705 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