i wanted to list down files found on a folder..so far it works but I also want it to be a link..one click and file will be downloaded..

<?php
// directory path can be either absolute or relative
$dirPath = '../kcfinder/upload/files';

// open the specified directory and check if it's opened successfully 
if ($handle = opendir($dirPath)) {

   // keep reading the directory entries 'til the end 
   while (false !== ($file = readdir($handle))) {

      // just skip the reference to current and parent directory 
      if ($file != "." && $file != "..") {
         if (is_dir("$dirPath/$file")) {
            // found a directory, do something with it? 
            echo "[$file]<br>";
         } else {
            // found an ordinary file 
            echo "$file<br>";
         }
      }
   }

   // ALWAYS remember to close what you opened 
   closedir($handle);
}
?>

I have to complement you on the great job you do with commenting your code. Well done!

Since you already have the file name, all you should need to do is wrap it in an achor tag. Try this:

echo "<a href=" . $file . ">Download File</a>";

Please ignore my reponse. For some reason, we posted our responses almost at the same time.

echo '<a href="'.$dirpath.'/'.$file.'"> Click here to download '. $file .'</a>';