您好,我想显示我的文件和目录。当它是文件时,我想显示最后更新的日期和大小。我的代码怎么了?
<?
$whole_path = ("../directory/");
$dirFiles = array();
if ($handle = opendir($whole_path)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != "index.php" && $file != "Thumbnails") {
$dirFiles[] = $file;
}
}
closedir($handle);
}
sort($dirFiles);
foreach($dirFiles as $file => $value)
{
$name = basename($value);
if(is_file($value))
{
$mod_date=date("d/m/Y H:i", filemtime($value));
$size = filesize($value);
}
?>
<tr>
<td><? echo $name; ?></td>
<td><? echo $mod_date; ?></td>
<td><? echo $size; ?></td>
</tr>
<?}?>
答案 0 :(得分:1)
您没有在文件名中添加$whole_path
,因此is_file()
查找的位置错误。 $value = $whole_path . $value;