File permissions 600?

See all posts Reply

File permissions 600? new!
by Dom, 16 years, 9 months ago
Just tried the class on my server. After uploading files using the class it sets them to 600. I have to manual change the permissions so they work in browser. is there a fix for this?
the photo dir is set to 777.

THANKS!

$handle->Process('/home/.../public_html/photos/');
Reply
Re: File permissions 600? new!
by colin, 16 years, 9 months ago
That depends on your server settings. The files are being created by PHP, thus belong to Apache. You can chmod the files, or else use umask() to set the default permissions.

I will probably add a new setting in the class so that the files created by the class can be automatically set with specific permissions.

A bit of information below, from this page
Files created with PHP have default permissions determined by the umask, short for unmask. This can be found by calling the umask() function with no arguments.

The file permissions set are determined by a bitwise and of the umask against the octal number 0777 (or the permissions specified to a PHP function which allows you to do so, such as mkdir("temp",0777) ). In other words, the permissions actually set on a file created by PHP would be 0777 & umask().

A different umask can be set by calling umask() with a numeric argument. Note that this does not default to octal, so umask(777) is not the same as umask(0777). It is always advisable to prefix the 0 to specify that your number is octal.

Given this, it is possible to change the default permissions by adding bits to the umask. A umask is "subtracted" from the default permissions to give the actual permissions, so if the default is 0777 and the umask is 0222, the permissions the file will be given are 0555
Reply
Re: File permissions 600? new!
by Dom, 16 years, 9 months ago
Would you happen to know at what line of the class i can specify umask(0755); ?

ThanksReply
Re: File permissions 600? new!
by colin, 16 years, 9 months ago
Before you call the class, not in the class.

Then, you will reset it to what it was, like this:
$old = umask(0755);
// do upload stuff here
umask($old);
Reply
Re: File permissions 600? new!
by Dom, 16 years, 9 months ago
Thanks for the quick reply.

After settig umask(0755); it appears that the last file that i was able to upload using the class became 0200(i think).

See my original was 0600. So since umask works minusing the original i dont know how to get it to become 0755. (what u mask to set)

another problem is that once i made the umask set and ran the script once. i since disabled the umask and now the class doesn't upload at all. the dir is empty. can this setting that i set have any affect on this. Im bafled since i haven't touched anything and it worked before.

Thanks
domReply
Re: File permissions 600? new!
by Dom, 16 years, 9 months ago
Sorry disregard my last post. the only problem i have it i dont know what yo set the umask to

the original permission is 600
and i would like them to be 755

would you happen to know what i should set the umask(); to?Reply
Re: File permissions 600? new!
by Dom, 16 years, 9 months ago
never mind got it solve umask(022);Reply