tags:

views:

65

answers:

3

I'm trying to create a directory on my server using PHP with the command:

mkdir("test", 0777);

But it doesn't give full permissions, only these:

rwxr-xr-x
+7  A: 

The mode is modified by your current umask, 0022 in this case.

The way the umask works is a subtractive one. You take the initial permission and subtract the umask to get the actual permission. 0777 - 0022 becomes 0755 which is rwxr-xr-x.

If you don't want this to happen, you need to set your umask to 0:

$oldmask = umask(0);
mkdir("test", 0777);
umask($oldmask);

See the PHP doco for umask and mkdir.

paxdiablo
+1  A: 

Probably, your umask is set to exclude those

Paul
A: 

The creation of files and directories is affected by the setting of umask. You can create files with a particular set of permissions by manipulating umask as follows :-

$old = umask(0);
mkdir("test", 0777);
umask($old);
Steve Weet