Open directory in server side and open files inside it
<p>I have a directory inside my server full of PDF files and I would like to open the file and be able to click on the name of the PDF and watch its content.  Now I only get the names of the files in a list but thats all.  I would like to press in the name and open the PDF.  </p>

<pre><code>&lt;?php 
$sub = ($_GET['dir']); 
$path = 'pedidos/'; 
$path = $path . "$sub"; 
$dh = opendir($path); 
$i=1; 
while (($file = readdir($dh)) !==   false) {
  if($file != "." &amp;&amp; $file != "..") {
      if (substr($file, -4, -3) =="."){
          echo "$i. $file &lt;br /&gt;";
      }else{                  
          echo "$i. &lt;a href='?dir=$sub/$file'&gt;$file&lt;/a&gt;&lt;br /&gt;";
      }
      $i++;
   } } 
closedir($dh); ?&gt;
</code></pre>
