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
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
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);
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);