如何在网页上显示文件夹内容?

时间:2014-03-07 01:46:31

标签: javascript php html web

我的问题有点令人困惑,但我想从文件夹中的文件夹中显示imga ..

Here is my page I'm working on,看到那些街区?我想自动从子文件夹中获取图像,并以这些块的样式列出它们。我自己可以自己处理造型部分,但有一种简单的方法可以做到这一点吗?

我是网络自动化的新手,我不知道如何解决这个问题。

1 个答案:

答案 0 :(得分:0)

php内置了一个读取目录类。

<?php

if ($handle = opendir('/path/to/files')) {
    echo "Directory handle: $handle\n";
    echo "Entries:\n";

    /* This is the correct way to loop over the directory. */
    while (false !== ($entry = readdir($handle))) {
        echo "$entry\n";
    }

    /* This is the WRONG way to loop over the directory. */
    while ($entry = readdir($handle)) {
        echo "$entry\n";
    }

    closedir($handle);
}
?>
相关问题