- opendir: documentation ( source)
- closedir: documentation ( source)
- readdir: documentation ( source)
- is_dir: documentation ( source)
- file_exists: documentation ( source)
<?php
$uploads_folder = "/home/yourUnixUsername/public_html/uploads/";
$web_folder = "/uploads/";
$image_requested = $_GET['pic']; // filename from url
$images = array();
if(file_exists($uploads_folder.$image_requested)) // if that image exists, get every image from that folder
{
if ($dh = opendir($uploads_folder))
{
$inc = 0;
while (($file = readdir($dh)) !== false)
{
if (!is_dir($uploads_folder.$file))
{
$images[$inc]=$web_folder.$file; // construct a web path to image
$inc++;
}
}
closedir($dh);
}
}
foreach($images as $an_image)
{
echo '<img src="'.$an_image.'">';
}
?>