Skip to content

Instantly share code, notes, and snippets.

@pradeep910
Created March 14, 2018 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pradeep910/4fd077ebe7412210c24a2a0d0bc2b0b3 to your computer and use it in GitHub Desktop.
Save pradeep910/4fd077ebe7412210c24a2a0d0bc2b0b3 to your computer and use it in GitHub Desktop.
Download PDF file
<?php
$file = "filename.ext";
// Quick check to verify that the file exists
if( !file_exists($file) ) die("File not found");
// Force the download
header("Content-Disposition: attachment; filename="" . basename($file) . """);
header("Content-Length: " . filesize($file));
header("Content-Type: application/octet-stream;");
readfile($file);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment