PHP 中的 chmod 777
如果我使用 mkdir() 在 php 中创建一个文件夹,它具有 www-data : www-data 用户和 755 权限。
问题是我无法使用 ftp 用户 (zapbe:psasrv) 删除此文件夹 我尝试在 php 中使用 chmod($path, "0777") 修改文件夹,但这不起作用。
如何使 www 数据和 ftp 用户都可以读取/删除创建的文件夹和上传的文件?
If I create a folder in php with mkdir() it has the www-data : www-data user and 755 permissions.
The problem is I can't delete this folder with the ftp-user (zapbe:psasrv)
I tried to modify the folder with chmod($path, "0777") in php but this doesn't work.
How can I make the created folders and uploaded files readable / removeable for both the www-data and the ftp-user?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在 PHP 中,它们可能对安全性有一些限制,因此根据您的配置,它可能无法工作。
上面的函数返回一个布尔值,让您知道它已成功更改实体权限。
还有一段 PHP 的引用:
了解上述内容后,您应该查看 chown
Within PHP they might be some limitations on the security, therefore the depending on your configuration it may not work.
The above function returns a booleon to let you know either it has succeed in changing the entities permissions.
Also a quote from PHP:
Understanding above you should look at chown
为了删除目录,您需要对父目录(而不是要删除的目录)具有写权限。为了提供对父级的写访问权限,一个好的方法是让该父级由 www-data 和您的 ftp 用户都是其成员的某个组拥有,并且永远不要使用 777 权限。另外,请确保您的父文件夹没有设置粘滞位。
In order to remove a directory, you need to have write permissions on the parent directory, not on the one you want to remove. In order to provide write access on the parent, a good approach would be to make that parent owned by some group that both www-data and your ftp user are members of, and never use the 777 permissioning. Also, make sure your parent folder does not have the sticky bit set.
默认情况下,当您在 *nix 中创建文件夹时,其他用户将无法删除/修改该文件夹。
要更改 www-data 创建的文件夹的权限,请从浏览器中运行 php 脚本中的命令,它应该会成功更新
一旦你这样做,任何人都可以修改文件夹
by default when you create a folder in *nix other users will not have the ability to delete/modify the folder.
to change the permissions of the www-data created folder, run the command in a php script from the browser and it should update successfully
Once you do that anyone can modify the folder
删除双引号并尝试检查文件的所有者
Remove the double quote and try and also check for the owner of file