I'm trying to save some text that comes into a php script via a POST to a file. Here is my script:
<?php
$path = $_SERVER['DOCUMENT_ROOT'];
$file = $path . '\test.txt';
$text = $_POST['text'];
// save it to a file
if (file_exists($file))
chmod($file, 0777);
$handle = fopen($file, 'w');
fwrite($handle, $text);
fclose($handle);
echo "success";
?>
I'm getting this error:
Warning: fopen(D:\Hosting\11347607\html\test.txt) [function.fopen]: failed to open stream: Permission denied in D:\Hosting\11347607\html\test_file_saver.php on line 12
I've tried a number of different attempts and read many posts. The directory is set to RWX permission. How can I get permission to write to this file? Thanks!