Skip to content

Instantly share code, notes, and snippets.

@mantismamita
Created April 20, 2015 20:42
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 mantismamita/899909f2ae5478cc6257 to your computer and use it in GitHub Desktop.
Save mantismamita/899909f2ae5478cc6257 to your computer and use it in GitHub Desktop.
Php function to force download a pdf
<?php
header('Content-Disposition: attachment; filename=' . urlencode($f));
header('Content-Type: application/force-download');
header('Content-Type: application/octet-stream');
header('Content-Type: application/download');
header('Content-Description: File Transfer');
header('Content-Length: ' . filesize($f));
echo file_get_contents($f);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment