[nycphp-talk] Setting directory permissions
Patrick Hunt
pat at vote.com
Fri Apr 18 19:34:16 EDT 2003
Jeff,
The value you pass into mkdir() is always AND'd with the current
umask. To be certain that the dir's permissions are set to exactly
what you pass, first clear the umask, as in:
if(!is_dir($id)) {
$root = getenv('DOCUMENT_ROOT');
$id = $root . '/pic_test/' . $id;
$old_umask = umask(0000);
mkdir($id,0777);
umask($old_umask);
}
You could just set umask to 0000 at the top of your script, but
make sure you understand the full ramifications of doing that.
Pat Hunt
--------------------------
On Fri, 18 Apr 2003 18:04:54 -0400, jsiegel1 at optonline.net wrote:
>I'm sure this is an easy one but...since I'm still learning PHP...I'm scratching my poor bald head. ;)
>
>Here's a code snippet:
>
>//create new directory with the id name if it doesn't exist, chmod to 777
>if(!is_dir($id)) {
> $root = getenv('DOCUMENT_ROOT');
> $id = $root . '/pic_test/' . $id;
> mkdir($id,0777);
>}>
>The problem is...this only works if I chmod the subdirectory "pic_test" to 777 using my FTP application. However, I want to quickly change the permissions via PHP code, upload some pictures with my form, then change the permissions back to 755.
>
>Thoughts/comments greatly appreciated.
>
>Jeff
>
>
>
>--- Unsubscribe at http://nyphp.org/list/ ---
>
>
>
More information about the talk
mailing list