PHP mkdir() permissions

谁都会走 提交于 2019-11-30 03:32:39

问题


I have a Linux server with appache as the web server. In my PHP script I am making directories with 0777 mode. the code is pretty simple as follows:

mkdir($path,0777)

when I run this script and go to my server file manager, the folder is there but the permission assigned to that folder is 0755. I can't figure out why this is happening!! when the folder is created the user column has apache in it but the permission is 0755.


回答1:


You should try with the umask

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



回答2:


You can try:

chmod ( string $filename , int $mode )

See if that can fix the permissions issue.




回答3:


Apache might not have the permissions to change this. What you can do is. Make sure that apache is running in the same group as your current files group. Then apache will be able to make changes to that file. You can change you apache group in this apache config. Or the easiest way is to change the entire project user to be the apache user. Then apache can make w.e changes it wants.

go to the file from your server and type ls -al and look at the user and group




回答4:


Could be your umask:

<?php
$old = umask(0);
mkdir($dir,0777);
mask($old);
?>


来源:https://stackoverflow.com/questions/7878784/php-mkdir-permissions

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