【发布时间】:2016-02-17 02:24:06
【问题描述】:
这段代码在 Xampp 上做了它应该做的事情(按字母顺序存储图像),但如果我将它上传到托管服务上,它会随机排序。
我已经试过了 natsort();但也许我实施错了。 我试过 scandir 但我没有找到图像(试图将路径更改为 rootpath 也没有工作)
<?php
$path = "./upload/outdoor/server/php/files/";
$dh = opendir($path);
$i=1;
while (($file = readdir($dh)) !== false) {
if($file != "." && $file != ".gitignore" && $file != "thumbnail" && $file != ".." && $file != "index.php" && $file != ".htaccess" && $file != "error_log" && $file != "cgi-bin") {
//Image Output
echo "<div>
<div href='$path/$file'>
<img src='$path/$file' />
</div>
</div>";
$i++;}
}
closedir($dh);
?>
【问题讨论】: