How to host a download file?

12 replies
  • WEB DESIGN
  • |
I want to place a pdf download link on my website so visitors can download the pdf. How do I do that? Thank you.
#download #file #host
  • Profile picture of the author Brandon Tanner
    Assuming the PDF file is placed in the same directory as the webpage...

    <a href="filename.pdf">Click here to download!</a>

    If it's in a different directory...

    <a href="relative/path/to/file/filename.pdf">Click here to download!</a>

    That said... if you want to force the user to download it (instead of just reading it in their browser), then put it in a zip file and then link to that zip file.
    Signature

    {{ DiscussionBoard.errors[7707382].message }}
  • Profile picture of the author iconoclast
    Thank you. Will this work in wordpress as well?
    {{ DiscussionBoard.errors[7708888].message }}
  • Profile picture of the author Patrick
    Yes it will work. However when you insert an HTML code, make sure the editor is "HTML" and not "Visual"
    {{ DiscussionBoard.errors[7708903].message }}
  • Profile picture of the author Michael71
    You can also use a "force download" script
    Signature

    HTML/CSS/jQuery/ZURB Foundation/Twitter Bootstrap/Wordpress/Frontend Performance Optimizing
    ---
    Need HTML/CSS help? Skype: microcosmic - Test Your Responsive Design - InternetCookies.eu

    {{ DiscussionBoard.errors[7708936].message }}
    • Profile picture of the author Istvan Horvath
      Originally Posted by Michael71 View Post

      You can also use a "force download" script
      ^^ that's a better solution: I hate when a zillion MB pdf file starts opening up in my browser because the author linked to it directly!

      Either zip it (zip files start downloading automatically) or ^^ what Michael said.
      Signature

      {{ DiscussionBoard.errors[7709069].message }}
      • Profile picture of the author Michael71
        Hahaha... yeah I know that

        I hate that, too...

        I have a force_download.php script somewhere on my HDD's...

        http://elouai.com/force-download.php

        Originally Posted by Istvan Horvath View Post

        ^^ that's a better solution: I hate when a zillion MB pdf file starts opening up in my browser because the author linked to it directly!

        Either zip it (zip files start downloading automatically) or ^^ what Michael said.
        Signature

        HTML/CSS/jQuery/ZURB Foundation/Twitter Bootstrap/Wordpress/Frontend Performance Optimizing
        ---
        Need HTML/CSS help? Skype: microcosmic - Test Your Responsive Design - InternetCookies.eu

        {{ DiscussionBoard.errors[7713236].message }}
  • Profile picture of the author David V
    Here's the short answer to what Istvan & Micheal71 recommended.
    Drop this into your htaccess file and keep it outside the WordPress hash tags (if using wordpress).
    Code:
    <FilesMatch ".(xls|csv|pdf)$">
      ForceType application/octet-stream
      Header set Content-Disposition attachment
    </FilesMatch>
    and a variation that's case insensitive.....
    Code:
    <FilesMatch ".(?i:pdf)$">
      ForceType application/octet-stream
      Header set Content-Disposition attachment
    </FilesMatch>
    I added the xls and csv, you can drop those, it's just an example of how to force any file type including, images, files, movies, etc..
    Chrome is sensitive about this, so here's a quick article that helps explain it.
    {{ DiscussionBoard.errors[7709310].message }}
  • Profile picture of the author blogfreakz
    you can try download manager plugins for wordpress, I used this plugins in my blog and my website.
    {{ DiscussionBoard.errors[7709529].message }}
  • Profile picture of the author KingRoyal
    That or you can use a wordpress download manager plugin, upload the pdf to the plugin, and then use a shortcode to download the pdf for your visitors

    Here is a great example,
    Adding and Storing Custom User Meta With Gravity Forms User Registration Addon | Wordpress ICUWordpress ICU
    {{ DiscussionBoard.errors[7709534].message }}
  • Profile picture of the author iconoclast
    I don't understand exactly what "force download" is? I just want my people to be able to download the pdf if they choose. I think just posting the zip file should be sufficient, no?
    {{ DiscussionBoard.errors[7711530].message }}
  • Profile picture of the author KingRoyal
    Yeah that should be fine however in an unlikely event the person who downloads the file may not have a zip software.
    {{ DiscussionBoard.errors[7711554].message }}
    • Profile picture of the author Istvan Horvath
      Originally Posted by johnathon4609 View Post

      Yeah that should be fine however in an unlikely event the person who downloads the file may not have a zip software.
      Which OS nowadays doesn't unzip it automatically? :rolleyes:
      Signature

      {{ DiscussionBoard.errors[7711726].message }}

Trending Topics