To list the files and directories inside a given directory with full path of the files use the following coding,
function list_directory($directory)
{
if ($handle = opendir($directory))
{
$output = array();
while (false !== ($item = readdir($handle)))
{
if (is_dir($directory.'/'.$item) and $item != "." and $item != "..")
{
$output[] = $directory.'/'.$item;
$output = array_merge($output, list_directory($directory.'/'.$item));
}
}
closedir($handle);
return $output;
} else { return false; }
}
$directory_list = list_directory('directoryname');
foreach($directory_list as $directory) { echo $directory.'
'; }