I am trying to write a php file to a file which is in the same folder. Both the php file and the file that it is trying to write have their permissions set to 777 (its linux server), as well as the folder in which they are located. Whenever I called fopen () with "w" or "w +" mode, the function simply returns false. This is on my school web server, so I can’t get root access to change the file owner to the same user as apache. Does anyone know what is wrong?
Update: As a test, I used this code:
$handle = fopen("test.txt", 'w');
if($handle === FALSE)
echo "\nfailed";
else
echo "\nsuccess";
fclose($handle);
Now the output with the error message turned on:
Warning: fopen(test.txt) [function.fopen]: failed to open stream: Permission denied in /<snip>/public_html/test.php on line 58
failed
Warning: fclose(): supplied argument is not a valid stream resource in /<snip>/public_html/test.php on line 63
Above this code, I copied the fileperms () function from the php website, which checks the permissions of the text file and its report -rwxrwxrwx
ls -al
ls -al *test*
-rwxrwxrwx 1 mag5 30 1475 Dec 9 00:02 test.php*
-rwxrwxrwx 1 mag5 30 8 Dec 8 14:54 test.txt*
, , , Andrew (http://en.wikipedia.org/wiki/Andrew_File_System).