<?php
//打开 images 目录
$dir = dir("images");//列出 images 目录中的文件
while (($file = $dir->read()) !== false)
{
echo "filename: " . $file . "<br />";
}$dir->close();
?> 
不用它不行吗?

解决方案 »

  1.   

    可以.
    <?php
    $dir = "/etc/php5/";// Open a known directory, and proceed to read its contents
    if (is_dir($dir)) {
        if ($dh = opendir($dir)) {
            while (($file = readdir($dh)) !== false) {
                echo "filename: $file : filetype: " . filetype($dir . $file) . "\n";
            }
            closedir($dh);
        }
    }
    ?>