Display images in a directory with php
Posted: February 28th, 2009 | Author: jriggs | Filed under: php | Tags: display, files, php | No Comments »Here’s a quick and dirty way to show all the files in a directory. I use this in my images folder to see what’s there. Some improvements would be to add a mime-type check or a *jpg check.
<?php
$path = "./";
$dir_handle = @opendir($path) or die("Unable to open folder");
while (false !== ($file = readdir($dir_handle))) {
if($file == "list2.php")
continue;
if($file == "list.php")
continue;
if($file == ".")
continue;
if($file == "..")
continue;
echo "<img src='$file' alt='$file' height=475 width=600><br />";
}
closedir($dir_handle);
?>
Related posts:
- Address Standardization & Verification with USPS web tools and PHP
- php: Create Url Safe Encrypted String