This is the code i use to do that
1) Insert the following code at the top of your html code
<?php
function allInDir($dir)
{
if (trim($dir) != "")
{
$handle = opendir($dir) or die("Directory \"$dir\"not found.");
while($entry = readdir($handle))
{
$entryArray[] = $entry;
}
sort($entryArray);
$loop = 0;
while ($loop < count($entryArray)) {
$instance = $entryArray[$loop];
if (strstr($instance, ".jpg")) {
echo "<font face=arial size=2><a href=\"$dir/$entryArray[$loop]\" target=\"_blank\">$entryArray[$loop]</a><br></font>";
}
$loop++;
}
}
}
?>
2) Insert the following code where you want the list of files to appear:
<?php allInDir($dir); ?>
3) Save your page as a php file (e.g. photodisplayer.php) and upload to your webspace.
4) Visit http://yourwebsite/photodisplayer.php?dir=DIRECTORY replacing yourwebsite with your website address, photodisplayer.php with the name you gave the php file, and DIRECTORY with the directory you wish to view.