What is umask ?
When user create a file or directory under Linux or UNIX, she create it with a default set of permissions. In most case the system defaults may be open or relaxed for file sharing purpose. For example, if a text file has 666 permissions, it grants read and write permission to everyone. Similarly a directory with 777 permissions, grants read, write, and execute permission to everyone. When a directory is created in PHP using mkdir and setting the permission to 0755 or to any other writable value, and if it still denys permission to add files inside that directory then we need to change the umask default value . For example
|
1 2 3 |
$oldumask = umask(0);
mkdir($directory,0775,true);
umask($oldumask); |
The umask() function in PHP changes the file permissions for files.
This function sets PHP’s umask to mask & 0777 and returns the old umask. However, if you call umask() without any arguments, it returns the current umask.







Dipak Karki 2:39 pm on March 28, 2012 Permalink |
Thanks to Jeremy Gomez, for providing this information