PHP permissions mkdir ()

I have a Linux server with appache as a web server. In my PHP script, I create directories with 0777 mode. the code is pretty simple:

 mkdir($path,0777) 

when I run this script and go to the file manager of my server, there is a folder, but the permission assigned to this folder is 0755. I can’t understand why this is happening !! when the folder is created, there is apache in the user column, but the resolution is 0755.

+6
source share
4 answers

You should try with umask

 $old = umask(0); mkdir($path,0777); umask($old); 
+21
source

You may try:

 chmod ( string $filename , int $mode ) 

See if this can fix the permission problem.

+3
source

Apache may not have permission to change this. What can you do. Make sure apache is running in the same group as your current file group. Then apache will be able to make changes to this file. You can change your apache group in this apache configuration. Or the easiest way is to change all project users to Apache users. Then apache can make we the changes it wants.

go to the file from your server and enter ls -al and look at the user and group

0
source

Maybe your umask:

 <?php $old = umask(0); mkdir($dir,0777); mask($old); ?> 
0
source

Source: https://habr.com/ru/post/899975/


All Articles