Results 1 to 6 of 6

Thread: Adding a Download Link

  1. #1
    Join Date
    Jan 2006
    Posts
    234
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Question Adding a Download Link

    Hi.

    I want to add a download link to a PDF file for example that is on my webserver so that if someone clicks on that link that the file will be downloaded and not opens up in a browser window.
    Can someone tell me how to configure a link like this please?

    Thank you very much.

    Cheng

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    PDFs are downloaded by default. Only plugins support "opening them in a browser". Acrobat reader kinda embeds itself into the browser to act like it's opening in it, but it's just an annoyingly scaled down version of the standalone application.

    So, because of this, it will be hard to control the way it's handled by the browser.

    Using php, you can specify a filetype and tell the browser to download, not open, the file, but Internet Explorer just ignores this.
    This means there isn't really a way, but you could use php to make it do so for those users not using IE.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jan 2006
    Posts
    234
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    .......thanks for your reply.
    So it seems there is no way to get it done in general.
    Could it be done with a selfextracting exe file?
    I think that could be a option or is it not?
    Thanks again for your help.......Cheng......

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    As I said, you can specify that it's a "force-download" type link using php, though IE will ignore that. That's as close as you'll get.

    However, yes, you can use another file type that won't open, like a self extracting exe or zip. I'd highly recommend zip over exe because 1. zips aren't as dangerous as exes. Unless people really trust you, they likely won't want to run an exe as that is a huge security risk. A zip, on other hand, is a lot less of a risk, and is still quite compatible. 2. zips are mac compatible.

    Anyway, yeah, that's the way you'd force a download if you need it to not be able to open in the browser.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Jun 2006
    Location
    Birmingham
    Posts
    39
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Arrow advice for downloading files from links

    you could put a statement next to the link saying that if it doesn't automatically download when clicked, to right click it and choose "save target as". ... or put that advice in a link called "can't download?"...or something similar.

    good luck!

  6. #6
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by djr33
    As I said, you can specify that it's a "force-download" type link using php ...
    If you're referring to "application/force-download", do not use that. If one is to "invent" content types, they should use the experimental/private prefix.

    To specify content is arbitrary binary data (for download), it should be labelled "application/octet-stream". Ideally, though, the content type sent will be accurate (that is, application/pdf), and the user should choose either explicitly (selecting a "Save As..." option) or implicitly (instruct their browser how to handle the type).

    Mike

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •