title: Download Selected File from Directory with PHP
body: <p>I have a script written (below) which properly displays the contents of a specific directory and creates a radio button for each file.  I would like to be able to select a file and download that file to my computer.</p>
  
  <p>Is this possible by changing the "action" of the form?  Or is there another script or a change I need to make to my script to accomplish this?</p>
  
  <pre><code>    &lt;form name="myform" action="#" method="POST"&gt;
  
  
  
  &lt;?php
  $dirPath = dir('./images');
  $imgArray = array();
  while (($file = $dirPath-&gt;read()) !== false)
  {
    if ((substr($file, -3)=="gif") || (substr($file, -3)=="jpg") || (substr($file, -3)=="png"))
    {
       $imgArray[ ] = trim($file);
    }
  }
  $dirPath-&gt;close();
  sort($imgArray);
  $c = count($imgArray);
  for($i=0; $i&lt;$c; $i++)
  {
      echo "&lt;input type=\"radio\" name=\"group1\" value=\"" . $imgArray[$i] . "\"&gt;" . $imgArray[$i] . "&lt;br /&gt;";
  }
  ?&gt;
  &lt;/select&gt;
  
  &lt;input type="submit" value="download"&gt;
  </code></pre>