[英]scandir fail to open directory
I am having trouble with scandir()
. 我在使用
scandir()
时遇到了麻烦。 I am trying to display the files in my snaps
-directory on a page under the subdomain in my cloud. 我正在尝试在我的云中的子域下的页面上显示我的
snaps
-directory中的文件。
This is the PHP I used. 这是我用过的PHP。
$files = scandir('./snaps');
print_r($files);
and this is the error. 这是错误。
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
I have no idea what else to do. 我不知道还能做什么。
您可能认为,当前工作目录是写入脚本scandir()
旁边,(在许多情况下)不是。
scandir(__DIR__ . '/snaps');
Given that error, your snaps directory would have to have the absolute path of 鉴于该错误,您的snaps目录必须具有绝对路径
/home/u703778423/public_html/cloud/snaps
Make sure that this is the correct location for the directory, and that the webserver has the rights to access it. 确保这是目录的正确位置,并且Web服务器有权访问它。
First off you're trying to display a few files that will not render as images... ex. 首先,你试图显示一些不会呈现为图像的文件......例如。 (.zip).
(。压缩)。
Also are you making sure you're not trying to display the first two index values " . " and " .. "? 你也确定你没有尝试显示前两个索引值“。”和“..”? I'm thinking this part of your code might not be the issue...
我在想这部分代码可能不是问题......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.