如果我在php中使用mkdir()创建一个文件夹,它有www-data:www-data user和755权限.
问题是我无法用ftp-user删除这个文件夹(zapbe:psasrv)
我尝试用php中的chmod($path,“0777”)修改文件夹,但这不起作用.
如何为www-data和ftp-user创建可读/可删除的创建文件夹和上传文件?
解决方法:
bool chmod ( string $filename , int $mode )
在PHP中,它们可能对安全性有一些限制,因此根据您的配置,它可能不起作用.
上面的函数返回一个booleon,让你知道它是否成功更改了实体权限.
if(!chmod($directory,0777))
{
echo "Unable to chmod $direcotry";
}
PHP的引用:
The current user is the user under which PHP runs. It is probably not the same user you use for normal shell or FTP access. The mode can be changed only by user who owns the file on most systems.
理解上面你应该看看chown
标签:php,linux,permissions,chmod
来源: https://codeday.me/bug/20191008/1872008.html