Reputation: 145
Hi I want to show to table my files and directories. And when it is files I want to show date of last update and size. Whats wrong with my code please?
<?
$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>
<?}?>
Upvotes: 0
Views: 52
Reputation: 11482
You are not adding $whole_path
to the filename, so is_file()
is looking in the wrong place. $value = $whole_path . $value;
Upvotes: 1