Source code:
<?php//specify our two variables for accessing the directory.
//replace "folder" with your folder name
$fileDir = $_SERVER['DOCUMENT_ROOT'] . '/uploads/';
$urlloc = "http://".$_SERVER['HTTP_HOST'] . '/uploads/';
//we're creating a list of files, so we start it
$result = "<ul>";
//opendir function opens the folder for reading
$handle = opendir($fileDir);
//while loop, which continues to execute until the
//readdir function finishes traversing the directory
while (($file = readdir($handle)) !== FALSE) {
//this allows the list to include links to subdirectories
if (is_dir($fileDir . $file)) continue;
//for each file, place a link to the file in the list
//by appending it onto $result
$thisfile = $file;
$result.= "<li>".$thisfile."</li>";
}
//close off the list
$result.= "</ul>";
//print the output to the screen
echo $result;
?>









Source code:
<?php//specify our two variables for accessing the directory.
//replace "folder" with your folder name
$fileDir = $_SERVER['DOCUMENT_ROOT'] . '/gallery/';
$urlloc = "http://".$_SERVER['HTTP_HOST'] . '/gallery/';
//we're creating a list of files, so we start it
$result = "<div class=\"gallery\">";
//opendir function opens the folder for reading
$handle = opendir($fileDir);
//while loop, which continues to execute until the
//readdir function finishes traversing the directory
while (($file = readdir($handle)) !== FALSE) {
//this allows the list to include links to subdirectories
if (is_dir($fileDir . $file)) continue;
//selecting only jpg images
if (!eregi('^.*\.jpg$', $file)) continue;
//for each file, place a link to the file in the list
//by appending it onto $result
$thisfile = $file;
$result.= "<img src=\"".$urlloc.$thisfile."\" alt=\"\" />";
}
//close off the list
$result.= "</div>";
//print the output to the screen
echo $result;
?>