eldan88 Posted February 15, 2013 Share Posted February 15, 2013 Hey, I have created a directory named new using the mkdir function... mkdir("new", 0777); When I created the directory it set the permessions to be 765.. I belive it set used the default permessions 0022 to get that value. My question is how can apply umask to change it back to 0777? Thank you! Link to comment https://forums.phpfreaks.com/topic/274502-how-to-change-permessions-with-umask/ Share on other sites More sharing options...
requinix Posted February 15, 2013 Share Posted February 15, 2013 You mean it created it as 0755? The umask will disable those bits: 0777 & ~(0022) = 0755. $oldumask = umask(0); mkdir("new", 0777); umask($oldmask); However I wouldn't change the umask at all. It's easy to forget to change it back. mkdir("new"); chmod("new", 0777); Link to comment https://forums.phpfreaks.com/topic/274502-how-to-change-permessions-with-umask/#findComment-1412542 Share on other sites More sharing options...
eldan88 Posted February 15, 2013 Author Share Posted February 15, 2013 You mean it created it as 0755? The umask will disable those bits: 0777 & ~(0022) = 0755. $oldumask = umask(0); mkdir("new", 0777); umask($oldmask); However I wouldn't change the umask at all. It's easy to forget to change it back. mkdir("new"); chmod("new", 0777); Thanks for your answer. I have another question..what does is the purpost of the 0 interger that goes after the perenthisis of the umask function Link to comment https://forums.phpfreaks.com/topic/274502-how-to-change-permessions-with-umask/#findComment-1412551 Share on other sites More sharing options...
kicken Posted February 15, 2013 Share Posted February 15, 2013 what does is the purpost of the 0 interger that goes after the perenthisis of the umask function The umask function takes one argument, which is the new umask to use. By doing umask(0) you're passing in 0 as the new umask, which essentially disables it. Link to comment https://forums.phpfreaks.com/topic/274502-how-to-change-permessions-with-umask/#findComment-1412557 Share on other sites More sharing options...
eldan88 Posted February 17, 2013 Author Share Posted February 17, 2013 The umask function takes one argument, which is the new umask to use. By doing umask(0) you're passing in 0 as the new umask, which essentially disables it. That makes sense thanks! Link to comment https://forums.phpfreaks.com/topic/274502-how-to-change-permessions-with-umask/#findComment-1412868 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.