更改权限以允许 PHP 列出用户目录中的文件夹
我有一个 Debian 的 VPS,我想在上面为拥有 SSH 帐户的人创建某种下载网站。我的问题是我想用 PHP 制作一个脚本,它将从用户主文件夹中的特定目录递归列出所有文件。该脚本很容易编写,但现在我遇到了权限问题。例如,文件夹是 /home/someuser/resources 并且它包含:
-file.txt [file]
-info.doc [file]
-data [dir]
---numbers.xls [file]
---people.txt [file]
-mail.doc [file]
不幸的是,在使用 PHP 和绝对路径列出此目录后,我得到的
-file.txt [file]
-info.doc [file]
-data [file] <- ?
-mail.doc [file]
是。 is_dir('/home/someuser/resources/data') 返回 false。正如我在互联网上读到的那样,问题在于许可。我将 /etc/php5/cgi/php.inisafe_mode_gid 更改为 Off 但没有帮助。我认为我需要更改 chmod。但怎样才能让它确实发挥作用呢?你能帮我解决这个问题吗?
我使用的脚本: http://pastie.org/private/vxnhpkkisintjmncinqzw (这是根据 PHP 手动注释更改的脚本)
I have a VPS with Debian and I want to make some kind of download site on it for people with SSH accounts. My problem is that i want to make a script in PHP which will list all files recursively from specyfic directory in users home folders. The script was easy to write but now I have problem with permissions. For example the folder is /home/someuser/resources and it contains:
-file.txt [file]
-info.doc [file]
-data [dir]
---numbers.xls [file]
---people.txt [file]
-mail.doc [file]
Unfortunately after listing this directory using PHP and absolute path I get
-file.txt [file]
-info.doc [file]
-data [file] <- ?
-mail.doc [file]
Yes. is_dir('/home/someuser/resources/data') return false. As i read in internet the problem is with permission. I changed in /etc/php5/cgi/php.inisafe_mode_gid to Off but it didn't help. I think that i need to change chmods. But how to make it work for sure? Can you help me with this?
Script which I use:
http://pastie.org/private/vxnhpkkisintjmncinqzw (it's a changed script from PHP manual comments)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第 8 行:语义:
while (false !== ...)
使while (...)
成立。从阅读您的代码来看,您似乎在读取目录方面做得很好,但您没有解析显示其内容的嵌套数组。因此,在读取和存储文件时,它们不会被打印出来。
Line 8: semantic:
while (false !== ...)
make thatwhile (...)
.From reading your code, it appears that you're doing a fine job of reading the directory out, but that you're not parsing the nested arrays that show its contents. Thus, while files are read and stored, they're not printed out.