Why can't PHP create a directory with 777 permissions?

Viewed 88034

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
6 Answers

In my case, I have to use the following way for centos7, which solved the problem

$oldmask = umask(000);//it will set the new umask and returns the old one 
mkdir("test", 0777);
umask($oldmask);//reset the old umask

More details can be found at https://www.php.net/manual/en/function.umask.php

Related