Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

daspenceman11

macrumors newbie
Original poster
Feb 22, 2009
4
0
Hi i am using dreamweaver 8 and am making a website. On the website i have a page where people can view/download pdf directions. I have it set up so you can view the PDF directions in the browser but i want to add another button where they can directly download the PDF straight off of the site without having to right click anything or open anything..

To make it short i want to be able for the user to click text that says "Click Here" and for a PDF to automatically download to their computer. Please PLEASE help!!
 
Example #1 Download dialog

If you want the user to be prompted to save the data you are sending, such as a generated PDF file, you can use the » Content-Disposition header to supply a recommended filename and force the browser to display the save dialog.

Code:
<?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');
?>


from http://php.net/manual/en/function.header.php#AEN123154

via http://www.pixel2life.com/forums/index.php?showtopic=25814
via http://www.google.de/search?client=...oe=UTF-8&redir_esc=&ei=lt6YS6WQAcv8_AbcwvDMCw
 
Ok this is a little complicated for me. Do you think you could give me step by step directions? Thanks!
 
You can take a look at a solution I posted a while back that's similar, though I was forcing in browser viewing and stopping hot-linking. Just change the content-disposition from inline to attachment like mentioned above.

If you can't figure this out, it's probably safer to tell user's to right-click and choose save because you could end up with insecure PHP code that could create security issues for your web site.
 
It might be easier just to say "right click to save to your computer" near the actual link.

The only other way I've ever found is to make a Zip archive of the PDF. When the user clicks on the link for MyPDFFile.zip the browser will (usually) automatically try to download it. The user will then have to unZip it, although some systems will do that automatically depending on their settings.

Another way that I haven't tried or looked at is to make the link an FTP instead (e.g. ftp://MyPDFFile.pdf) of HTTP, which might force the PDF to be downloaded, but you may need to have special settings on your host webserver for that to work.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.