<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Use finfo</title>
<style>
thead tr {
background-color: #AAAAAA;
}
tbody tr:nth-child(even) {
background-color: #EEEEEE;
}
</style>
</head>
<body>
<?php
$dirname = '../super2/imgs/';
$dir = dir($dirname);
echo '<table border="1" cellpadding="3" style="border-collapse:collapse">';
echo '<caption style="margin-bottom:4px">Image List</caption>';
echo '<thead><tr><th>Name</th><th>MIME Type</th></tr></thead><tbody>';
$finfo = new finfo(FILEINFO_MIME_TYPE);
while ($filename = $dir->read()) {
if ($filename{0} == '.') {
continue;
}
echo '<tr>';
echo "<td><input type=\"text\" value=\"$filename\" size=\"5\"></td>";
printf('<td><input type="text" value="%s" size="10"></td>', $finfo->file($dirname . $filename));
echo '</tr>';
}
echo '</tbody></table>';
$dir->close();
?>
</body>
</html>