php 不会删除 775 目录 chmod
好的帮助我理解这一点。
我的 Linux 系统中有 2 个用户,它们都是“web-users”组的一部分。
一种是网络服务器和 php-cgi 使用的 www-data 一个是我的 ftp 用户,
当我通过 ftp 上传文件时,目录设置为 775,文件设置为 664,当我在服务器上运行脚本(与 ftp 用户相同的组)以删除该目录和其中的文件时: unlink对于文件工作正常,但命令 rmdir 不起作用返回权限被拒绝!?是的,目录被清空后被删除。
为什么775意味着该组的用户可以删除它,就像文件的664一样。
谢谢!
OK help me understand this.
I have 2 users in my linux system that are BOTH part of "web-users" group.
one is www-data used by the webserver and php-cgi
one is my ftp-user
when I upload files via ftp they are set to 775 for dirs and 664 for files, when I run a script on the server (so same group like the ftp user) to delete that directory and files inside: unlink for files works ok but the command rmdir doesnt work returning permission denied!? And yes the directory is deleted after is emptied.
why is that 775 means that the group's user can delete it just like 664 for files.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以检查包含您尝试删除的目录的
父级
的权限
。本周早些时候,我删除了一些脚本生成的目录,即使将它们的权限设置为
777
,我仍然收到“权限被拒绝”的消息,直到我授予自己对该目录的Write
访问权限。父
目录。You might check the
permissions
of theparent
that contains the directory you're trying to delete.I was deleting some script-generated directories earlier this week and even with their permissions set to
777
, I was still getting "permission denied" until I gave myselfWrite
access to theparent
directory.我之前遇到过同样的问题,我的代码如下所示:
我自己认为这是权限问题,但事实证明我只需要在
rmdir
-ing 之前调用linedir
。所以:也许你的问题和我的类似?
I encountered the same problem before and my code looked like below:
I myself thought that it was permission issue but it turned out that I just needed to call
closedir
beforermdir
-ing. So:Maybe your problem is similar to mine?
您不能在包含文件的目录上使用 rmdir()。在使用 rmdir() 删除目录之前,该目录必须为空。
You can't use rmdir() on a directory that contains files. The directory must be empty before you use rmdir() to delete it.