简体   繁体   English

php中的mkdir()将文件夹权限设置为755但是我需要777吗?

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

I am trying to create a folder on my server using php when i set it to 0777 it comes out as 755? 我正在尝试使用php在我的服务器上创建一个文件夹,当我将其设置为0777时它出现为755?

mkdir($create_path, 0777);

Thank you 谢谢

Try this: 试试这个:

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

http://php.net/umask http://php.net/umask

Try this: 试试这个:

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

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

Reference 参考

This really works for me!, you should close now this question! 这真的对我有用!你现在应该关闭这个问题!

  1. Create the directory! 创建目录!
  2. Give 777 permissions! 授予777权限!

     $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! 好好享受!

进程的umask设置为0022.如果要创建具有这两个写入位的东西,则需要将其设置为0。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM