phpretard Posted April 17, 2009 Share Posted April 17, 2009 I have files that normally you would right click or control click to download (pdf, doc, ect...). Is there any way to just left click and open a "save or open window" like a what happens with a .zip file? Quote Link to comment https://forums.phpfreaks.com/topic/154494-solved-auto-download-a-pdf/ Share on other sites More sharing options...
premiso Posted April 17, 2009 Share Posted April 17, 2009 Maybe with javascript. But not with PHP. Especially a PDF since the plugin effects the browser to auto-open that type. Quote Link to comment https://forums.phpfreaks.com/topic/154494-solved-auto-download-a-pdf/#findComment-812315 Share on other sites More sharing options...
mtoynbee Posted April 17, 2009 Share Posted April 17, 2009 Use headers: <?php // We'll be outputting a PDF header('Content-type: application/pdf'); // It will be called downloaded.pdf header('Content-Disposition: attachment; filename="downloaded.pdf"'); // The PDF source is in original.pdf readfile('original.pdf'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/154494-solved-auto-download-a-pdf/#findComment-812317 Share on other sites More sharing options...
phpretard Posted April 17, 2009 Author Share Posted April 17, 2009 Thanks for the help! Quote Link to comment https://forums.phpfreaks.com/topic/154494-solved-auto-download-a-pdf/#findComment-812324 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.