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

前端 未结 6 1401
小鲜肉
小鲜肉 2020-11-27 12:07

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, on

6条回答
  •  遥遥无期
    2020-11-27 13:04

    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

提交回复
热议问题