scandir,readdir,opendir fonksiyonları ile bu işlemleri yapabilirsin. Örnek olarak php.net sitesini incelemeni öneririm.

http://php.net/manual/en/function.scandir.php

Örnek uygulama :

$imgdir = 'images/'; //Pick your folder
$allowed_types = array('png','jpg','jpeg','gif'); //Allowed types of files
$dimg = opendir($imgdir);//Open directory
while($imgfile = readdir($dimg))
{
if( in_array(strtolower(substr($imgfile,-3)),$allowed_types) OR
in_array(strtolower(substr($imgfile,-4)),$allowed_types) )
/*If the file is an image add it to the array*/
{$a_img[] = $imgfile;}
}
echo "
    ";

    $totimg = count($a_img); //The total count of all the images
    //Echo out the images and their paths incased in an li.
    for($x=0; $x < $totimg; $x++){echo "
  • ";}
    echo "
";
?>