I use the following method to get a list of images to display on a webpage to dynamicaly hyperlink a description to.
I wrote this for a linux filesystem, but it should work the same in a windows environment.
/**
* Return the names of files from $filePath
* @param string $dirPath The path to the directory to get the contents of.
* @return array Returns an array of file names. If an error occurs, return false.
*/
function getDirectoryContents($dirPath)
{
// Return a list of image names from the directory.
if ($handle = opendir($dirPath))
{
// array counter
$i = 0;
// Loop over the directory.
while (false !== ($dir = readdir($handle)))
{
// Do not include "." and ".." as filenames.
if ($dir != '.' && $dir != '..')
{
// Assign variable
$fileName[$i] = $dir;
// Increment Counter
$i++;
}
}
// Close the directory
closedir($handle);
return ($fileName);
}
else
return (false);
}
Hope that helps.
-a9