【发布时间】:2014-01-02 18:48:55
【问题描述】:
这曾经位于http://elijahhoffman.com/index.php?q=editorial&z=one,现在位于http://elijahhoffman.com/editorial/one
用于读取“galleries/editorial_i”的文件夹路径;但它不起作用,我认为是因为新的路径位置......所以我将完整的 url 附加到路径中,它仍然不起作用......想法?
<?php
$folder = 'http://elijahhoffman.com/galleries/editorial_i/';
$handle = opendir($folder);
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..') {
$files[] = $file;
}
}
closedir($handle);
sort($files);
foreach ($files as $file) {
print <<<EOF
<img src="{$folder}/{$file}" class="imgfullmargin" alt="{$file}"/>
EOF;
}
?>
【问题讨论】:
-
$folder的值不是一个目录,它是一个 url,可能不支持目录列表:据我所知,只有 file:// 和 ftp://支持这个,不是 http:// -
根据specs,“4.3.0 路径也可以是任何支持目录列表的 URL,但是 PHP 4 中只有 file:// URL 包装器支持。”
-
php.net/opendir#refsect1-function.opendir-changelog,如您所见,您无法使用 http://,只能使用 file:// 和 ftp://