title: How to download a file from specific directory using php header
body: <p>I have some code to download file using php header but it is not properly working and want to add directory to read  </p>
  
  <pre><code>    &lt;?php
  if(isset($_GET['link'])){
      $var_1 = $_GET['link'];
  $dir='/upload/';
  }
  ?&gt;
  &lt;?php
  if(isset($_GET['link'])){
      $var_1 = $_GET['link'];
  $file = $var_1;
  if (file_exists($file)) {
      header('Content-Description: File Transfer');
      header('Content-Type: application/octet-stream');
      header('Content-Disposition: attachment; filename='.basename($file));
      header('Expires: 0');
      header('Cache-Control: must-revalidate');
      header('Pragma: public');
      header('Content-Length: ' . filesize($file));
      ob_clean();
      flush();
      readfile($file);
      exit;
  }
  echo "&lt;h1&gt;Content error&lt;/h1&gt;&lt;p&gt;The file does not exist!&lt;/p&gt;";
  }
  ?&gt;
  </code></pre>
  
  <p>It shows error 
  Content error</p>
  
  <p>The file does not exist!</p>
  
  <p>I am Using </p>
  
  <blockquote>
    <p><a href="http://sap.layyah.info/download.php?link=UAC.dll" rel="nofollow">http://sap.layyah.info/download.php?link=UAC.dll</a></p>
  </blockquote>
  
  <p>this link to download the file file original location is </p>
  
  <blockquote>
    <p><a href="http://sap.layyah.info/upload/UAC.dll" rel="nofollow">http://sap.layyah.info/upload/UAC.dll</a></p>
  </blockquote>