Why, when I try to rename a directory, do I get "permission denied" in PHP?

I chmod'ed the directory to 777, the same with the contents of the directory. However, I get a "permission denied" error. Does PHP provide this error if apache is not a group / owner, regardless of file permissions? Here's a call that doesn't work:

rename('/correct/path/to/dir/1', '/correct/path/to/dir/2');
+5
source share
5 answers

You are editing a higher level directory, so a PHP user needs write access to this directory.

+11
source

, apache . ( ) , .

+2

, php , :

-rwxrwxrwx user   user   temp/
-rwxr-xr-x apache apache temp2/
-rw-r--r-- user   user   script.php

, script.php :

// this operation fails as PHP (running as apache) does not own "temp",
// despite having write permissions    
rename('temp', 'temp.bak');

// this operation is successful as PHP owns "temp2"
rename('temp2, 'temp.bak'); 
+2

script:

print_r(posix_getpwuid(getmyuid()));
print_r(pathinfo($YOUR_PATH));

, .

0

, - . , apache , . , .

0

All Articles