Default permissions when uploading files

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
lovasco
Forum Newbie
Posts: 15
Joined: Fri May 17, 2002 4:25 am
Location: Milan - Italy

Default permissions when uploading files

Post by lovasco »

Dear Folks,
I have seen that a default permission of 755 is automatically set by php when uploading a new file to a UNIX machine.
I would like to know whether it is possible to change this default parameter so that files are stored with a permission of 644.
Thanks a lot,
Luca
pootergeist
Forum Contributor
Posts: 273
Joined: Thu Feb 27, 2003 7:22 am
Location: UK

Post by pootergeist »

you could chmod the file once you've moved it from /tmp/

move_uploaded_file(............, 'path/'.$filename);
chmod('path/'.$filename,0644);
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

you might be as well interested in http://www.php.net/manual/de/function.umask.php
lovasco
Forum Newbie
Posts: 15
Joined: Fri May 17, 2002 4:25 am
Location: Milan - Italy

Post by lovasco »

I didn't know I could issue the chmod command; it belongs to the Filesystem functions and works fine.
Thanks you,
Luca
Post Reply