如果我使用 mkdir() 在 php 中创建一个文件夹,它具有 www-data : www-data 用户和 755 权限。
问题是我无法使用 ftp 用户 (zapbe:psasrv) 删除此文件夹 我尝试在 php 中使用 chmod($path, "0777") 修改文件夹,但这不起作用。
如何使创建的文件夹和上传的文件对 www 数据和 ftp 用户都可读/可删除?
最佳答案
bool chmod ( string $filename , int $mode )
在 PHP 中,它们可能对安全性有一些限制,因此根据您的配置,它可能无法工作。
上述函数返回一个 bool 值,让您知道它是否已成功更改实体权限。
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 - php 中的 chmod 777,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5019194/