Click to See Complete Forum and Search --> : How can I copy files and directories and keep their original file permissions?


OM2
07-13-2007, 06:33 PM
How can I copy files and directories and keep their original file permissions?
(This is specifically referring to Linux hosting... but I would have thought the question would apply for any platform.)

For example, amongst others, I will have myFile.xml and myFilesDirectory.
Both have file permissions 777.

Is there anything I can do to guarantee that copies made of both will keep their file permissions?

Thanks.


OM

NogDog
07-13-2007, 09:01 PM
You could use fileperms (http://www.php.net/fileperms)() to get the current permission, then chmod (http://www.php.net/chmod)() to set the same permission on the copied/moved file. However, be cognizant that if your script is run as an Apache module, the Apache user will be considered the owner of any file copy, regardless of who the owner was of the source file.

OM2
07-18-2007, 10:46 AM
thanks for the reply.
i'm having a mini application developed.
and am wondering if there is any way *NOT* to have the user need to log in via FTP and change file and directory permissions?

i assumed not.
since for application like phpbb (and others), you need to login and manually change file permission?

why do they not use the command you have suggested i use?

thanks.

OM2
07-19-2007, 06:04 PM
erm... no answer...?
let me know if you know.
thanks.