Loading images from a directory with PHP
2010-04-27
This is how you can use PHP to display all of the images in a directory (folder) where the PHP page lives.
<?php
$files = glob("*.jpg");
$fileCount = count($files);
for ($i = ($fileCount-1); $i >= 0; $i--) {
echo '<img src="'.$files[$i].'" alt="" width="450px">';
}
?>
Note: this will only display images with the extension .jpg. You will have to modify it to display other image types (png, gif, etc.).