Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Cannot write to file even though it has 777 permissions
    text
    copied!<p>Im trying to make a php file write to a file that resides in the same folder. Both the php file and the file its trying to write to have their permissions set to 777 (its a linux server) as well as the folder they reside in. Whenever I called fopen() with the 'w' or 'w+' mode, the function just returns false. Its on my school's webserver, so there is no way I can get root access to change the owner of the file to the same user as apache. Does anyone know whats wrong?</p> <p>Update: As a test, I was using this code:</p> <pre><code>$handle = fopen("test.txt", 'w'); if($handle === FALSE) echo "\nfailed"; else echo "\nsuccess"; fclose($handle); </code></pre> <p>The output now with error reporting enabled is:</p> <pre><code>Warning: fopen(test.txt) [function.fopen]: failed to open stream: Permission denied in /&lt;snip&gt;/public_html/test.php on line 58 failed Warning: fclose(): supplied argument is not a valid stream resource in /&lt;snip&gt;/public_html/test.php on line 63 </code></pre> <p>Above that is some code I copied from the php website for the fileperms() function which checks the permissions of the text file, and its reporting -rwxrwxrwx</p> <p>The ls -al output of the relevant files is </p> <pre><code>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* </code></pre> <p>Also Im not sure if this matters, but my school uses something called the Andrew File system (<a href="http://en.wikipedia.org/wiki/Andrew_File_System" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Andrew_File_System</a>).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload