In Feburary 2016 25,
The list of permissions you supply to the 'mkdir' function are valid only on Linux-based file systems. This means you cannot associate permissions with a directory you create under Windows. If you pass permissions with the 'mkdir' function under Windows, PHP simply ignores them.
Default User Account
Remember that a script run on a Web server from a browser runs under the default user account on the Web server such as 'www-data,' not under your user account. If directory permissions are not working, it may be because you are testing a script under your account instead of the default user account. You can test the script as the default user by typing 'su www-data' and exploring the directory permissions assigned to that user.
Directory Mask
If the resulting permissions of a new directory are different from what you passed, it may be because of a directory mask applied to the permissions. The mask is maintained by the Web server, not by PHP. To circumvent the mask, use the 'umask' function to set the mask to zero, create the directory using 'mkdir' and change the directory permissions using the 'chmod' function. For example:
$save = umask(0);
if (mkdir($newdir)) chmod($newdir, 0755);
umask($save);
?>
Recursive Assignment
The 'mkdir' function takes a second optional argument that creates nested directories recursively. When you assign directory permissions recursively, the permissions may not be executed in the proper order and you might get different results from what you expected. To ensure the proper order, use the 'chmod' function to assign directory permissions to the new directory after you create it with the 'mkdir' function. For example:
if (mkdir($newdir, 0755, true)) chmod($newdir, 0755);
?>
In Feburary 2016 25,