PHP mkdir or chmod 0777 doesn't work

旧时模样 提交于 2019-12-13 19:13:13

问题


I have a small script that create a directory for a user who registers an account on my site. This director is used to store images in that they upload.

When I use mkdir() with permissions of 0777, the directory is created under the users name, but the permissions stay as 0755.

I have tried a few different ways to do this, as follows;

$path = path/to/directory/and/filename

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

also;

$path = path/to/directory/and/filename/

mkdir($path, 0777, true);

also;

$path = path/to/directory/and/filename/

mkdir($path);
chmod($path,0777);

When I create a directory myself in the ftp client the owner and group is me, but when the php script created them, it has the owner and group of apache/apache'. I don't think if this is anything to do with it?

I have spent a good while trying to figure this out, and I have also spent a fair amount of time searching on this forum and others, so any help would be amazing!

If there is any other information required, I can provide. Thanks!

来源:https://stackoverflow.com/questions/29589933/php-mkdir-or-chmod-0777-doesnt-work

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