Writing to file using PHP on IIS

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

Who is Participating?
nplibConnect With a Mentor Commented:
change the permission on the C:\Inetpub\wwwroot\ for the IUSR user to have write privileges
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
cescentmanAuthor Commented:
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.
cescentmanAuthor Commented:
So simple but so effective, fantastic thanks.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.