chmod() not working correctly

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tristanlee85
Forum Contributor
Posts: 172
Joined: Fri Dec 19, 2003 7:28 am

chmod() not working correctly

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

umask() is limiting your setting, as the documentation page for mkdir() specifically says.
tristanlee85
Forum Contributor
Posts: 172
Joined: Fri Dec 19, 2003 7:28 am

Post 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.
Post Reply