ディレクトリ内ファイル一覧表示
<?php
$DIR = "../../sample"; //一覧表示するディレクトリ
function printfile($dir) {
$opendir = opendir($dir);
while($file = readdir($opendir)) {
if($file === "." or $file === "..") {
continue;
}
$file = $dir . "/" . $file;
if(is_dir($file)) {
printfile($file);
continue;
}
if(preg_match("/\.s?html$/", $file) and filesize($file) > 100) {
$filename = preg_replace("/^[\.\/]+/", "", $file);
echo "<a href=\"$file\">$filename</a><br>\n";
}
}
closedir($opendir);
}
?>
<html>
<head>
<title>ディレクトリ内ファイル一覧</title>
</head>
<body>
<?php
printfile($DIR); //ファイル一覧表示
?>
</body>
</html>
〔 実行する 〕