Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Writing to file using PHP on IIS

Posted on 2007-11-28
Medium Priority
Last Modified: 2012-06-27
I am using PHP on my IIS server.

I am trying to write to a file using PHP in a file at http://localweb/local/Management/testfile.php. I want it to write to an exsiting file:-


testfile.php contains the following attached code snippet.

I have set the open_basedir in PHP.INI and phpinfo reports it to be:-


I am getting the error message:-

"Warning: fopen(Files\Registrations\test.txt) [function.fopen]: failed to open stream: Permission denied in C:\Inetpub\wwwroot\Local\HostingManagement\testfile.php on line 4"

I have tried various combinations of paths etc and none of the give me any joy.

Can anyone suggest how I get this working, or what I am doing wrong?

$filename = "Files\\Registrations\\test.txt";
$newdata = "test data";

Open in new window

Question by:cescentman
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
  • 2
LVL 20

Expert Comment

ID: 20366387
First try

$filename = "Files".DIRECTORY_SEPARATOR."Registrations".DIRECTORY_SEPARATOR."test.txt";

if that doesnt work then try

$filename = "Files".DIRECTORY_SEPARATOR."Registrations".DIRECTORY_SEPARATOR."test.txt";


if that doesnt work then open your ftp software and set the permissions from there.

Right click on the file you should see something like permissions or attributes then change them

Author Comment

ID: 20366725
I will try this but does chmod have any effect on a windows server? there is no need for ftp as in this case the path is local and I'm not using ftp.
LVL 17

Accepted Solution

nplib earned 2000 total points
ID: 20367246
change the permission on the C:\Inetpub\wwwroot\ for the IUSR user to have write privileges

Author Comment

ID: 20368638
So simple but so effective, fantastic thanks.

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

A phishing scam that claims a recipient’s credit card details have been “suspended” is the latest trend in spoof emails.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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

618 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