View folder Images Index

View folder Images Index

Posted By: mitsurug1 on Mar 06, 2005

Index your images on a page

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>";
?>
  • Comment on this tutorial
  • View the Printable Version

Posted On: Mar 06, 2005

Hits: 4629 - Unique: 3702

Advertise Here!

Quick Tutorial Search

VDC - Visual Design Core on Facebook

Our Popular Tutorials

Signature Backgrounds

Abstract Wave Technique

Abstract Airbrushing

Cinema 4d Materials Tutorial

Rusty Metal Plate

Dark Art Guide

Trendy Grunge Background

Abstract Renders in Cinema 4d