title: Download a pdf's file code in php
body: <pre><code>$path = BASE_URL."/pdf/"; 
  $filename= $path.basename($_GET['download_file']);
  
  header("Cache-Control: public");
  header("Content-Description: File Transfer");
  header('Content-disposition: attachment; 
  filename='.basename($filename));
  header("Content-Type: application/pdf");
  header("Content-Transfer-Encoding: binary");
  header('Content-Length: '. filesize($filename));
  readfile($filename);
  exit;
  </code></pre>
  
  <p>This code works but I'm getting <code>Error in reading pdf file</code> when opening the downloaded pdf. In the above code I get the file from the location <code>http://localhost//eec//pdf/CV_Prabin Mishra.pdf</code></p>