| | |||||||
| |||||||
| |||||||
|
|
|
|
|
|
|
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; ?>
More File Manipulation Code Articles |
| |
| |