rendered paste body<?php
$dir = 'files';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>View Directory Contents</title>
</head>
<body>
<h2>Contents of <? echo($dir); ?></h2>
<table>
<tr>
<td><b>Preview:</b></td>
<td><b>Filename:</b></td>
</tr>
<?php
$class_iterator = new RecursiveDirectoryIterator($dir);
foreach(new RecursiveIteratorIterator($class_iterator) as $file)
{
echo('<tr>');
$info = pathinfo($file);
if(ereg("jpg|jpeg|gif|tiff|tif|png", $info['extension']))
{
$image = 1;
}
if($image)
{
echo('<td><img src="' . $file . '" /></td>');
}
else
{
echo('<td>No preview available</td>');
}
echo('<td>');
echo('<a href="' . $file . '">' . $file . '</a>');
echo('</td>');
echo('</tr>');
}
?>
</table>
</body>
</html>