[nycphp-talk] Setting directory permissions
pat at vote.com
Fri Apr 18 19:34:16 EDT 2003
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:
$root = getenv('DOCUMENT_ROOT');
$id = $root . '/pic_test/' . $id;
$old_umask = umask(0000);
You could just set umask to 0000 at the top of your script, but
make sure you understand the full ramifications of doing that.
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
> $root = getenv('DOCUMENT_ROOT');
> $id = $root . '/pic_test/' . $id;
>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.
>--- Unsubscribe at http://nyphp.org/list/ ---
More information about the talk