[nycphp-talk] Setting directory permissions
jsiegel1 at optonline.net
jsiegel1 at optonline.net
Fri Apr 18 20:01:18 EDT 2003
Pat,
Thanks for the help. Unfortunately I didn't have any luck with this. I wonder if it has to do with the permissions that PHP is running under, that is, PHP itself does not have the permission needed to create the directory. (Am I making sense or am I confusing apples and oranges?)
Jeff
----- Original Message -----
From: Patrick Hunt <pat at vote.com>
Date: Friday, April 18, 2003 7:34 pm
Subject: Re: [nycphp-talk] Setting directory permissions
> 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