scandir无法打开目录 [英] scandir fail to open directory

查看:193
本文介绍了scandir无法打开目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用scandir()时遇到麻烦.我正在尝试在云子域下页面上的snaps-目录中显示文件.

I am having trouble with scandir(). I am trying to display the files in my snaps-directory on a page under the subdomain in my cloud.

这是我使用的PHP.

$files = scandir('./snaps');
print_r($files);

这是错误.

Warning: scandir(./snaps) [function.scandir]: failed to open dir: No such file or directory in /home/u703778423/public_html/cloud/index.php on line 39

Warning: scandir() [function.scandir]: (errno 2): No such file or directory in /home/u703778423/public_html/cloud/index.php on line 39

我不知道该怎么办

推荐答案

您可能会假设当前工作目录位于编写脚本scandir()的旁边,而在很多情况下不是. >

You probably assume, that the current work directory is next to the script scandir() is written in, which (in many cases) isn't.

scandir(__DIR__ . '/snaps');

这篇关于scandir无法打开目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆