Home › Forums › JavaScript › automatic pdf download › Reply To: automatic pdf download
January 11, 2017 at 1:47 pm
#249928
Participant
This one’s handy to force a download dialogue and not open the file:
https://css-tricks.com/snippets/htaccess/force-files-to-download-not-open-in-browser/
Beverley’s posted the exact terms to find the solution but let me just add what I’ve been using:
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="anyname.pdf"');
header('Expires: 0');
header('Cache-Control: no-cache, no-store, must-revalidate');
header('Pragma: no-cache');
readfile('path/correctname.pdf');