title: search folder on server and display results
body: <p>How do I search a folder on my server and display the results on my webpage?  I found a similar question at <a href="https://stackoverflow.com/questions/8613962/how-can-i-create-a-search-form-that-searches-files-in-a-folder">How can I create a search form that searches files in a folder?</a> but I can't figure out how to connect the php script to my html:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  
  &lt;div&gt;
  &lt;input id="query" type="text"/&gt;&lt;button id="search-button"  onclick="?????"&gt;Search&lt;/button&gt;
  &lt;/div&gt;
  
  &lt;script&gt;
  var q=document.getElementById("query");
  
  
  
  &lt;/script&gt;
  
  
  &lt;?php
  $dir = "/uploads/";
  
  // Open a known directory, and proceed to read its contents
  if (is_dir($dir)) {
  if ($dh = opendir($dir)) {
      while (($file = readdir($dh)) !== false) {
          if($file == $_POST['q']){
              echo('&lt;a href="'.$dir . $file.'"&gt;'. $file .'&lt;/a&gt;'."\n");
          }
      }
      closedir($dh);
  }
  }
  ?&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>