Showing posts with label How to make PDF file downloadable in PHP. Show all posts
Showing posts with label How to make PDF file downloadable in PHP. Show all posts

Thursday, 25 April 2013

How to make PDF file downloadable in PHP

 - To Make PDF as downloadable in PHP,


 $filename = '/path/to/your/file/download.pdf';
  header("Pragma: public");
  header("Expires: 0"); 
  header("Pragma: no-cache"); 
  header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0,pre-check=0");  
  header("Content-Type: application/force-download"); 
  header("Content-Type: application/octet-stream");
  header("Content-Type: application/download");
  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(0);