mkdir() in php is setting folder permission to 755 But I Need 777?

匆匆过客 提交于 2021-01-21 12:33:11

问题


I am trying to create a folder on my server using php when i set it to 0777 it comes out as 755?

mkdir($create_path, 0777);

Thank you


回答1:


Try this:

$old_umask = umask(0);
mkdir($create_path, 0777);
umask($old_umask);

http://php.net/umask




回答2:


This really works for me!, you should close now this question!

  1. Create the directory!
  2. Give 777 permissions!

    $estructure = '../files/folderName';
    
    if(!mkdir($estructure, 0777, true)){
        echo "<br/><br/>ERROR: Fail to create the folder...<br/><br/>"; 
    }  else echo "<br/><br/>!! Folder Created...<br/><br/>";
    
    chmod($estructure, 0777);
    
  3. Enjoy it!




回答3:


Try this:

<?php
// files will create as -rw-------
umask(0);
// create a file, eg fopen()

chmod('/path/to/directory', 0777);
?>

Reference




回答4:


The umask of the process is set to 0022. You'll need to set it to 0 if you want to create something with those two write bits set.



来源:https://stackoverflow.com/questions/4134702/mkdir-in-php-is-setting-folder-permission-to-755-but-i-need-777

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!