PHP mkdir 0777 失败 chmod 0777 工作

标签 php chmod mkdir

使用 PHP 5.2.14,会发生这种情况

[user@VE213 public_html]$ php -r "mkdir('directory', 0777);"
[user@VE213 public_html]$ ls -lt
drwxrwxr-x  2 rankranger rankranger 4096 Dec  8 17:28 directory

[user@VE213 public_html]$ php -r "chmod('directory', 0777);"
[user@VE213 public_html]$ ls -lt
drwxrwxrwx  2 rankranger rankranger 4096 Dec  8 17:28 directory

在 php bug 列表中没有找到任何相关的 bug,有什么想法吗?

最佳答案

$old = umask(0);
mkdir($dir,0777);
umask($old);

读这个, http://php.net/manual/en/function.mkdir.php

此外,检查您创建新目录的顶级目录。

示例)

pwd /data/log

$dir="/data/log/query";
$old = umask(0); 
mkdir($dir,0777); 
umask($old); 

/data/log must 0777.

关于PHP mkdir 0777 失败 chmod 0777 工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4390422/

相关文章:

php - 使用 XAMPP Server Linux (Ubuntu) 在 Laravel 4 上迁移时找不到驱动程序

php - 无法在 OpenCart (PHP) 中禁用错误​​报告

php - 测试查询构建器

git - 如何使github上传的文件chmod=+x?然后使用 wget 命令下载文件并在 github 模式下保留可执行集?

C检查目录是否存在的更快方法

Android - 创建自己的文件夹以保存相机拍摄的图像

php - Order By 不适用于连接和分组的 MySQL 表

PHP session 文件权限

linux - 将可执行属性扩展到所有用户

gnu-make - 当 mkdir -p 不可用时如何在 makefile 中创建目录?