Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

rename('/correct/path/to/dir/1', '/correct/path/to/dir/2');
like image 293
Andrew Hedges Avatar asked Oct 12 '08 21:10

Andrew Hedges


2 Answers

You're editing the higher level directory, so the PHP user needs to have write access to that directory.

like image 65
acrosman Avatar answered Oct 15 '22 19:10

acrosman


Thats probably because apache is not the owner of the parent directory. Renaming (or moving) a file is basically the same thing as creating a new file.

like image 27
kjensen Avatar answered Oct 15 '22 20:10

kjensen