Make A PHP Directory To List Out All The Images From A Directory

Last Edited: 2015-12-23 22:26:20

I wrote this a long time ago and have been adding little simple bits to it along the way. Drop this script into a directory on a server and then navigate to it in your favorite browser to it and you'll get a list with thumbnails of all of your images. All other files that are not images will show up as broken links; I'll probably fix that someday.




<table>
<tr>
<?php
$i=0;
$dir = ".";
$handle = opendir($dir);
while($file = readdir($handle)){
if($file != "." && $file != ".."){
$is = getimagesize($file);
?>
<td><center>
<a href="<?php echo $file; ?>" target="_blank">
<img src="<?php echo $file; ?>" <?php if($is[0]>200){ ?> width="200"<?php } ?> border="0">
</a><Br>
<?php echo $file; ?> <?php echo $is[0]."x".$is[1]; ?></center></td>
<?php if($i==4){
$i=0; ?>
</tr><tr>
<?php } else {
$i++;
}
}
}
?>


Comments

Categories

Recent Posts