Gallery Script Code with images as default folder...
<?
function CheckExt($filename, $ext) {
$passed = FALSE;
$testExt = ".".$ext."$";
if (eregi($testExt, $filename)) {
$passed = TRUE;
}
return $passed;
}
//Define an array of common extensions.
$exts = array("gif","jpg$|\.jpeg","png","bmp");
echo "<b>Images in this folder:</b>";
$dir = opendir("images");
$files = readdir($dir);
while (false !== ($files = readdir($dir))) {
foreach ($exts as $value) {
if (CheckExt($files, $value)) {
echo "<a href=\"images/$files\"><img src=\"images/$files\"width=\"160\" height=\"120\" alt=\"gallery\"></a>\n";
$count++; //Keep track of the total number of files.
break; //No need to keep looping if we've got a match.
}
}
}
echo $count." image(s) found in this directory.\n";
echo "<a href=\"".$_SERVER["PHP_SELF"]."\">Refresh</a>\n";
//Be a good script and clean up after yourself...
closedir($dir);
?>