Read files from directory and display link to download

Hello all,

I am trying to display all the files in my directory and display them in html as links, for the user to download.
I am able to display the files but when i click on them , nothing happens. as i am a beginner, i must have gone wrong some where in my PHP
Please go through my code which is pasted below…
thanks for looking into the issue

<?php
  $dir = "C:/wamp/www/NetOptUI2/NetOptUI2/NetOptUI2/files/";
  if ($handle = opendir($dir)) {
      while (false !== ($entry = readdir($handle))) {
          if ($entry != "." && $entry != "..") {
              echo "<a href='".$dir."/".$entry."'>$entry</a><br/>";
          }
      }
      closedir($handle);
 }
 ?>

I changed the php code as below and it works now

<?php
      $dir = "C:/wamp/www/NetOptUI2/NetOptUI2/NetOptUI2/files/";
      if ($handle = opendir($dir)) {
          while (false !== ($entry = readdir($handle))) {
              if ($entry != "." && $entry != "..") {
                  echo "<a href=".$entry.">$entry</a><br/>";
              }
          }
          closedir($handle);
   }
   ?>
Sponsor our Newsletter | Privacy Policy | Terms of Service