PHP mkdir 0777 fail chmod 0777 works

孤街浪徒 提交于 2019-11-29 07:18:30
Hyeonju Kim
$old = umask(0);
mkdir($dir,0777);
umask($old);

Read this, http://php.net/manual/en/function.mkdir.php

Additional, Check the top directory that you make new directory.

Example)

pwd /data/log

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

/data/log must 0777.

This is not a bug. See http://php.net/umask - you probably have an umask of 0002. The permission of what you create is yourmode & ~umask, so it takes the write-bit for everyone away from 0777.

Tyler Eaves

Working as documented. mkdir respects umask, chmod doesn't.

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