file permissions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Nicolaas
Forum Newbie
Posts: 3
Joined: Sun Aug 03, 2003 12:24 pm

file permissions

Post 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 ?
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post 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
Nicolaas
Forum Newbie
Posts: 3
Joined: Sun Aug 03, 2003 12:24 pm

Post by Nicolaas »

what should the permissions for the directory be to which the file is being written ?
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post 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.
Post Reply