Page 1 of 1
file permissions
Posted: Sun Aug 03, 2003 12:43 pm
by Nicolaas
what do the file ownerships need to be for my script to be able to run
imagejpeg()?
do all users need write permission ?
Posted: Sun Aug 03, 2003 12:47 pm
by m3rajk
i have a php image adjusting script that apache runs, i own, is in a group apache is not part of, and the permissoin on the file are 644.
calling it from a browser on a remote computer works fine as long as the images i access are accessable
Posted: Sun Aug 03, 2003 1:00 pm
by Nicolaas
what should the permissions for the directory be to which the file is being written ?
Posted: Sun Aug 03, 2003 1:20 pm
by McGruff
Nicolaas wrote:what should the permissions for the directory be to which the file is being written ?
If php needs to write a file to a folder, it must have the write permission for that folder. The three numbers in - say - a folder set at 755 refer to owner/groups/joe public in that order.
So, if php is the owner of a 755 folder, it can write files there. If it's not, it can't.
How to make php the owner of a folder? Create the folder with php & mkdir(). (If you browse the site in your ftp program, you'll see the owner/groups for folders & files). Note that your ftp program can't write or delete files to a php-owned 755 folder.
Also, note that, if you create a folder with your ftp program, php is not the owner. However, if the folder is set to 777, you can write a file to it with a php script. The file itself is owned by php so, if you chmod the folder back to 755, php can update the file despite not having write permission in the folder as a whole. This is useful if you merely want to update a file with php while maintaining access to other files in the folder with your ftp program.