View folder Images Index


This script creates a index of all images in a folder.
PHP Code:
<?php
$ext_arr 
= array("jpg","png","gif");
$ext $_GET['ext'];
$handle=opendir('.');
if(!isset(
$ext)){
$strSought "jpg";
}else{
if(
in_array($ext$ext_arr)){
   
$strSought $ext;
 }else{
   
$strSought "jpg";
 }
}
$num 0;
while (
$file readdir($handle)) {
if (
$strSought == substr($file, -3)) {
 
$num $num 1;
    }
}
closedir($handle);
$handle=opendir('.');
echo 
"There are $num $strSought files!

"
;
echo 
"<ul>\n\t";
foreach(
$ext_arr as $key){
echo(
"<li><a href=\"".$_SERVER['PHP_SELF']."?ext=$key\">$key</a></li>\n\t");
}
echo 
"</ul>";
echo
"<table>";
echo 
"<tr>\n\t<th>Files:</th>\n\t<th>Width</th>\n\t<th> </th>\n\t<th>Height</th>\n\t<th>Size</th>\n</tr>";
while (
$file readdir($handle)) {
if (
$strSought == substr($file, -3)) {
      
$size GetImageSize($file);
        
$fullsize intval(filesize($file)*.001);
           echo 
"<tr><td><a href=$file>$file</a></td><td>  <b>$size[0]</b></td><td> by</td><td> <b>$size[1]</b>:</td><td> $fullsize kb</td></tr>";
}
}
closedir($handle);
echo
"</table>";
?>

Quick Tutorial Search