PHP mkdir() permissions

前端 未结 4 2017
北海茫月
北海茫月 2021-01-04 23:00

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

<         


        
相关标签:
4条回答
  • 2021-01-04 23:13

    You can try:

    chmod ( string $filename , int $mode )
    

    See if that can fix the permissions issue.

    0 讨论(0)
  • 2021-01-04 23:15

    Could be your umask:

    <?php
    $old = umask(0);
    mkdir($dir,0777);
    mask($old);
    ?>
    
    0 讨论(0)
  • 2021-01-04 23:24

    Apache might not have the permissions to change this. What you can do is. Make sure that apache is running in the same group as your current files group. Then apache will be able to make changes to that file. You can change you apache group in this apache config. Or the easiest way is to change the entire project user to be the apache user. Then apache can make w.e changes it wants.

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

    0 讨论(0)
  • 2021-01-04 23:33

    You should try with the umask

    $old = umask(0); 
    mkdir($path,0777); 
    umask($old); 
    
    0 讨论(0)
提交回复
热议问题