<?php
  $filesPath = "/var/wwwdata/downloads/";
  
  function printList($path)
  {
    $fd = opendir($path);
    if(!$fd) return false;
    while (($file = readdir($fd)) !== false){
      if(is_dir($path.$file)) continue;
      echo("<li><a href=\"http://localhost/download.php?name=");
      echo("$file\">$file</a></li>");
    }
    closedir($fd);
  }
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Moja strona WWW</title>
  </head>
  <body>
    <div>
      <ul>
      <?php
        printList($filesPath);
      ?>
      </ul>
    </div>
  </body>
</html>
