How To Force A PDF Download.

by 16 replies
18
Hey Gang,

Now I'm sure I'm using the wrong tech lingo here but hopefully my point gets across (and I hope I'm in the right forum!).

I've been searching around Google for a while now and can't for the life of me figure out how to link from an email and have the user automatically download a PDF file.

Here's my situation.

I'm writing an email series for my list and want to distribute PDF files through my follow up system. The files are too large for Aweber so I would like to host the file on my site like site.com/download, link to that extension from my email and have the PDF file start downloading automatically.

I don't know if that's just a script I need or whatever but either way I'm completely lost and would REALLY appreciate some help/guidance on this :-).

Thanks gang,

--Curt
#programming #download #force #pdf
  • Hi Curt,

    You can't control whether or not the user's email system automatically downloads pdf files. But you can make the link clear and invite the user to download.

    Inside your email, have the link to the file.
    For example:
    Hey subscriber, I want to make sure you get my new pdf file. It's at:
    http://www.mysite.com/downloads/latest.pdf
    If your email system doesn't download it automatically, be sure to click the link above to get the latest pdf file.
    P.S. I have virus scanned this file and I know that it's safe for both Windows and Mac.

    Of course you might want to explain some more about the benefits of the file, etc.

    Chris
    • [1] reply
    • Hey Chris,

      Thanks for your response but that wasn't exactly what I was looking for.

      I know that I need to get them to click on my link, but what I don't know how to do is once they click the link in the email, have that link download and open up a pdf on my server.

      That's what I'm looking to do :-).

      Thanks!

      --Curt
      • [1] reply
  • Banned
    [DELETED]
  • A simpler way to say it:

    1) Copy the code start from <?php to ?> posted by saschakimmel (post #4)
    2) Save it as "dl.php" or whatever name you want.
    3) Put the "dl.php" into the same folder with the pdf file you want you subscribers to download.
    4) Now you give away the link like this:
    http://www.mysite.com/dl.php?file=yourfile.pdf

    Or, if you want to put up a page, use this HTML code
    <a href="http://www.mysite.com/dl.php?file=yourfile.pdf">Download</a>

    Note: The "http://www.mysite.com/" part can be omitted if your page is on the same folder of both "dl.php" and your pdf file.

    - Rufas
    • [ 1 ] Thanks
    • [1] reply
    • Thanks Rufas!

      You Rock!

      Worked like a charm but I do have one more question if you don't mind.

      I could figure out how to get my file to download if the file was simply one word like test.pdf.

      mysite.com/dl.php?file=test.pdf

      No problems there...

      But what if I have a file that's something along the lines of "first test.pdf"

      I couldn't figure out what the link would actually be for that.

      I tried
      mysite.com/dl.php?file=first test.pdf
      mysite.com/dl.php?file=first_test.pdf
      mysite.com/dl.php?file=first-test.pdf

      and none of those worked.

      The reason I'd like to know is because I'd really like to have the file with the full title (that has some copy in it :-)) so if the file happens to sit on their hard drive for days/months or whatever, and they happen to pass by it, it catches their eye and they read it and perhaps buy later.

      That's my ideal situation

      Let me know if you can help on that last technicality :-).

      Cheers!

      --Curt
      • [1] reply
  • Yup, that is ideally what I would like to do...

    With Firefox, the file does actually download but not with Safari.

    So with that being said, any suggestions for my other question then? How do I use the script with a file name that has multiple words in it i.e. "The Report"?

    Thanks!

    --Curt
  • Did %20 work where the spaces are? If not, wouldn't it be easier to just replace those spaces with dashes to be safe?

    Matt
  • Tried %20 but that didn't work for some reason... the dashes did work when I replaced the spaces with them...

    Thanks!

    --Curt
    • [1] reply
    • No problem! You should just avoid spaces in file names for the web. Especially if you are using the URL's in e-mail.
      • [1] reply
  • Another way is to add a .htaccess file into your pdf subfolder, and any pdf files in it will be downloadable right away:

    <Files *.pdf>
    ForceType application/octet-stream
    </Files>

Next Topics on Trending Feed