I have files like pdf in a directory and i have created a search form where in the user will input the filecode and it will search the source directory if it matches a filename it will allow the user to download the file, if not it will show "No Results" Here's what i did, but I am not sure what code should I use to download a file from my source directory, I just saw the code for downloading a file somewhere and substitute the source file with the variable i use when a user search
<html>
          <head>
            <title>Search  Contacts</title>
          </head>
          <body>
            <h3>Search Client File</h3>
            <form  method="post" action="#"  id="searchform">
              Type the File Code:<br><br>
                  <input  type="text" name="fcode">
            <br>
      <input  type="submit" name="submit" value="Search">
            </form>
<?php
$filecode=$_POST["fcode"];
     if (!empty($filecode))
     {
 $ch = curl_init();
$source = "/sdir/$filecode.pdf";
curl_setopt($ch, CURLOPT_URL, $source);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec ($ch);
curl_close ($ch);
$destination = "/tdir/afile.pdf";
$file = fopen($destination, "w+");
fputs($file, $data);
fclose($file);
     }
     else
     {
       echo "No Results";
     }
        ?>
    </body>
    </html>
 
     
    