PHP Cannot write a file even if it has 777 permissions

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).

+1
5

Telanor, AFS - .

AFS (Andrew File System) , unix. AFS , , . , , , - (, , , ). , AFS, , .

+5

:

$fh = fopen($filename, "a");

, , . , , "w" .

, / , , .

+2

, php , . php ( )?

0

, . , . , , , , - , . , NFS , PHP , .

, , 777. 666 . , .

, , , .

0

MadCoder sais. AFS: "ACL ACS " Unix ". AFS . Unix " group "" other " AFS.

. AFS :

read the file only if the owner read mode is set to "UNIX". write to the file only if the read and write modes of the UNIX owner are set. execute the file only if the read and execute modes of the UNIX owner are set. "

To set AFS permissions, you need to use the "fs setacl" command.

0
source

Source: https://habr.com/ru/post/1732768/


All Articles