class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
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.
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 0555Reply
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.
the photo dir is set to 777.
THANKS!
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
Thanks
Then, you will reset it to what it was, like this:
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
dom
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?