码迷,mamicode.com
首页 > Web开发 > 详细

php 遍历文件夹下的所有文件名以及文件大小

时间:2016-05-30 10:04:14      阅读:276      评论:0      收藏:0      [点我收藏+]

标签:

 

$num=0;    //用来记录目录下的文件个数
$dirname=‘files/faces‘; //要遍历的目录名字
$dir_handle=opendir($dirname);

echo ‘<table border="1" align="center" width="960px" cellspacing="0" cellpadding="0">‘;
echo ‘<caption><h2>目录‘.$dirname.‘下面的内容</h2></caption>‘;
echo ‘<tr align="left" bgcolor="#cccccc">‘;
echo ‘<th>文件名</th><th>文件大小</th><th>文件类型</th><th>修改时间</th></tr>‘;
while($file=readdir($dir_handle))
{
if($file!="."&&$file!="..")
{
$dirFile=$dirname."/".$file;
if($num++%2==0) //隔行换色
$bgcolor="#ffffff";
else
$bgcolor="#cccccc";
echo ‘<tr bgcolor=‘.$bgcolor.‘>‘;
echo ‘<td>‘.$file.‘</td>‘;
echo ‘<td>‘.filesize($dirFile).‘</td>‘;
echo ‘<td>‘.filetype($dirFile).‘</td>‘;
echo ‘<td>‘.date("Y/n/t",filemtime($dirFile)).‘</td>‘;
echo ‘</tr>‘;
}
}
echo ‘</table>‘;
closedir($dir_handle);

php 遍历文件夹下的所有文件名以及文件大小

标签:

原文地址:http://www.cnblogs.com/RainLi/p/5541330.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!