I didnt get what u told, but I am sending the exact code which i am using for executing. The problem it is showing all files in c:\, and more over I am not able to access them.
<?php
function dirList ($directory, $startpath)
{
$results = array();
$handler = opendir($directory);
while ($file = readdir($handler))
{
if ($file != '.' && $file != '..')
{
$nextDir = $directory."/".$file;
$results[] = preg_replace('%^'.preg_quote($startpath).'/%', '', $nextDir);
if(is_dir($nextDir))
{
$results = $results + dirList($nextDir, $startpath);
}
}
}
closedir($handler);
return $results;
}
$results=$_POST['results'];
$dir = dirname(""c:\php");//"c:\php";
$files = dirList($dir, $dir);
foreach ($files as $file) {
echo "<a href=\"$file\" title=\"$file\">$file</a><br>";
}
?>
Please make requried modifiction.I am new to PHP.