This code lets you display the images in a directory; limiting size - with option to display filesize - and filename.
It also lets you selective ignore files by name.
(may be a little sloppy, but its all mine)
By : Kender
<?
/* ************************************ ** James Wheeler ** Kender Internet Kompany ** http://kender.org ** ** Name as index.php ** - Display all images in a directory ** - Able to skip files at will ** - remove <img src= and use for ** all files in directory ** (skipping desired files) ** ** Code free to use, please give credit ** where credit is due! ************************************ */
echo '<center> Click on a thumbnail to view image<br /> <table> <tr> ';
$main = "."; $dir = opendir($main); // unbutton it $i = 1; // for column count
while($filename = readdir($dir)) { { if (filetype($filename) == "file" && $filename != "index.php") // dont show index.php (this file) - skip any file you dont want viewed // format as ( && $filename != "filename.ext" ) inside the () behind "index.php" { if ($i <= '5') // column count (designed for 5 columns wide - change the 5 for however many wanted) { $i = $i + '1'; echo ' <td align="left" width="115" height="100"> <a href="'.$filename.'"><img src="'.$filename.'" height="60" border="0" /></a><br /> <font size="1" face="tahoma">'.$filename.'<br />'.filesize($filename).' bytes.</font> </td> '; // display it } else { $i = '1'; // reset column count and change rows echo ' </tr> <tr> '; $i = $i + '1'; // add 1 to counter to get to next row echo ' <td align="left" width="115" height="100"> <a href="'.$filename.'"><img src="'.$filename.'" height="60" border="0" /></a><br /> <font size="1" face="tahoma">'.$filename.'<br />'.filesize($filename).' bytes.</font> </td> '; // display it } } } }
closedir($dir); // button it up
echo ' </tr> </table> </center> ';
exit; ?>
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.