php - File upload works, but can't move file to another directory -


my project directory /public_html/test/

ownership , permission below,

drwxrwsr-x 8 lamp apache 4096 apr  8 10:46 public_html drwxrwsr-x 6 lamp apache 4096 apr  2 14:58 test 

a web application create directory, upload files, move files 1 directory other directory under directory /public_html/test/files/

drwxrwsr-x 21 lamp apache 4096 apr 24 13:58 files 

now problem is, created directory called "mydirectory" using web application, created under /public_html/test/files/ below,

drwxrwsrwx 2 apache apache   4096 apr 15 13:56 mydirectory 

then uploaded 1 file "myfile.jpg", default uploaded /public_html/test/files/

-rwxrwxrwx 1 apache apache 595284 apr 15 13:58 myfile.jpg 

then code use php function "move_uploaded_file" move file /public_html/test/files/ /public_html/test/files/mydirectory/ below

move_uploaded_file('/public_html/test/files/myfile.jpg', '/public_html/test/files/mydirectory/myfile.jpg'); 

it doesn't work. how fix this?

if change ownership of /public_html/test/files/mydirectory/ lamp:apache instead apache:apache, , upload file again, move_uploaded_file works fine.

note: user "lamp" belongs "apache" group.

===================

php safe_mode on, made off , worked :)

this line:

move_uploaded_file('/public_html/test/files/myfile.jpg', '/public_html/test/files/mydirectory/myfile.jpg'); 

should like:

move_uploaded_file('/public_html/test/files/myfile.jpg', '/public_html/test/files/mydirectory'); 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -