I provide this directory & file:
$path = $_POST['q2Path'];
$file = "test.txt";
// q2Path == "C:\Users\micah\Desktop\only_dir_named_this"
The code runs this block:
$write_str = "TEST TEST TEST";
$fh = fopen($file, 'a') or die("can't open: $path\\$file");
$chars = fwrite($fh, $write_str) or die("can't write to: $path\\$file");
fclose($fh) or die("can't close: $path\\$file");
echo "<pre>> Appended $chars characters to: $path\\$file</pre>";
This is the browser output:
Appended 14 characters to: C:\Users\micah\Desktop\only_dir_named_this\test.txt
And in the end, the file is empty and the ‘last modified’ timestamp hasn’t changed. I’m not sure what’s up. I’m using ZendServer on Win7. Perhaps there’s a php.ini setting that needs adjustment? I’ve never had a problem with a simple file write…
You write
$path\\$file, but you dofopen($file, 'a')It should be