(安西) 发表于 2017-3-28 11:43:47

浏览目录内容的php代码举例

php简单浏览目录内容的代码一例。
代码如下:
<?php
/**
* 浏览目录中内容
* by www.jbxue.com
* date 2013-6-8
*/
$dir = dirname(__FILE__);
$open_dir = opendir($dir);
echo "<table border=1 borderColor=red cellpadding=6>";
echo "<tr><th>文件名</th><th>大小</th><th>类型</th><th>修改日期</th></tr>";
while ($file = readdir($open_dir)) {
if ($file!= "." && $file != "..") {
echo "<tr><td>" . $file . "</td>";
echo "<td>" . filesize($file) . "</td>";
echo "<td>" . filetype($file) . "</td>";
echo "<td>" . filemtime($file) . "</td></tr>";
}
}
echo "</table>";
?>
页: [1]
查看完整版本: 浏览目录内容的php代码举例