Direct Download PDF's in Dreamweaver 8

Discussion in 'Mac Apps and Mac App Store' started by daspenceman11, Mar 10, 2010.

  1. daspenceman11 macrumors newbie

    Joined:
    Feb 22, 2009
    #1
    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!!
     
  2. spinnerlys Guest

    spinnerlys

    Joined:
    Sep 7, 2008
    Location:
    forlod bygningen
    #2
    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
     
  3. daspenceman11 thread starter macrumors newbie

    Joined:
    Feb 22, 2009
    #3
    Ok this is a little complicated for me. Do you think you could give me step by step directions? Thanks!
     
  4. spinnerlys Guest

    spinnerlys

    Joined:
    Sep 7, 2008
    Location:
    forlod bygningen
    #4
    I don't know PHP either, I just found it via using a web search engine.

    It might be easier just to say "right click to save to your computer" near the actual link.
     
  5. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #5
    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.
     
  6. Buzz Bumble Guest

    Joined:
    Oct 19, 2008
    Location:
    New Zealand
    #6
    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.
     

Share This Page