Page 1 of 1

chmod() not working correctly

Posted: Tue Jun 27, 2006 8:42 pm
by tristanlee85

Code: Select all

//User directory
if (!is_dir("users/".$user)) { //Checks to see if the directory exists
mkdir("users/".$user, 0777);
}
With that code, when the directory is created, it's actually setting permission at 0755 even though I've stated 0777. I tried using 0644 as a test and it created the directory as 0644, but 0777 won't work. Any ideas?

Posted: Tue Jun 27, 2006 8:47 pm
by feyd
umask() is limiting your setting, as the documentation page for mkdir() specifically says.

Posted: Tue Jun 27, 2006 9:02 pm
by tristanlee85
So I would want:

Code: Select all

//User directory
if (!is_dir("users/".$user)) { //Checks to see if the directory exists
umask(0777);
mkdir("users/".$user, 0777);
}
The weird thing is, I look at the other directors and they are chmod 0777. The only thing I changed on this script was changed the upload script from a PHP script to CGI.