Short story:
I'm getting an open_basedir restriction in my php script - a simple "test writing a new file to disk" script. It SEEMS to me that I've got the open_basedir settings correct and the file is in the right location - but no luck, just the same error every time. I've searched for similar open_basedir problems on this site, but I've not seen any with this problem - where the directory looks right but it still throws errors.
My guesses as to what the problem is:
1) open_basedir doesn't work the way I think it does
2) My settings are wrong and I'm just not seeing it
3) It's actually something else, like IIS read/write permissions, etc
4) ???
Long story:
I'm working on an IIS server with PHP and I'm trying to get the following code snippet to work (a simple write file test):
date_default_timezone_set('America/Chicago');
$myFile = 'testfile.txt';
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "Some Text\n";
fwrite($fh, $stringData);
$stringData = "Some More Text\n";
fwrite($fh, $stringData);
fclose($fh);
This php script is located at C:\inetpub\wwwroot\WEBDIRECTORY\test_write.php on my server
Here is my php.ini setting for open_basedir:
open_basedir = c:\inetpub\wwwroot;c:\inetpub\wwwroot\WEBDIRECTORY
Whenever I open the script's page, I am expecting to see no output, and then there should be a new file written on the server when I check back. This is what I get instead:
Warning: fopen(): open_basedir restriction in effect. File(testfile.txt) is not within the allowed path(s): (c:\inetpub\wwwroot) in C:\inetpub\wwwroot\WEBDIRECTORY\test_write.php on line 5 Warning: fopen(testfile.txt): failed to open stream: Operation not permitted in C:\inetpub\wwwroot\WEBDIRECTORY\test_write.php on line 5 can't open file
I've tried a lot of permutations: originally the open_basedir line was just
open_basedir = c:\inetpub\wwwroot
...but that didn't work, either.
I've also tried entering an absolute path for testfile.txt (c:\inetpub\wwwroot\WEBDIRECTORY\testfile.txt, etc) instead of just the name of the file itself, and I keep getting the same error message.
Any ideas? Thanks so much for your help.