File Downloads
Results 1 to 5 of 5

Thread: File Downloads

  1. #1
    rebmeM roineS enilnOitnA steve.milner's Avatar
    Join Date
    Jul 2003
    Posts
    1,018

    File Downloads

    First, my web skills are very limited, so be gentle.

    If you got to AO Security downloads, and actually download something you get to the point where a page is displayed suggesting that if the download does not start automatically, click here ...

    At the same time the download starts automatically.

    How is that done. I can start a page automatically by redirecting in a pages headers, but the I can't display that message.

    Any help appreciated.

    Steve
    IT, e-commerce, Retail, Programme & Project Management, EPoS, Supply Chain and Logistic Services. Yorkshire. http://www.bigi.uk.com

  2. #2
    AO Antique pwaring's Avatar
    Join Date
    Aug 2001
    Posts
    1,409
    The meta refresh seems to work fine for most sites that offer downloads this way:

    Code:
    <meta http-equiv="refresh" content="1; url=http://www.yoursite.com/downloads/file.zip">
    Stick that in the <head> area of your HTML file (or generate it automatically using PHP, ASP etc.) and it should work.

    You can also use JavaScript, something like this:

    Code:
    <body onLoad='window.location.href="http://www.yoursite.com/downloads/file.zip"'>
    Obviously, the second version will only work if JavaScript is enabled, but most browsers do have it switched on. The first version will work in pretty much any browser.

    The reason the above code snippets work is because browsers automatically recognise zip files etc. as being file types (or rather, MIME types) that can't be rendered by a browser and so they display a download box whilst leaving the original page in the background. This wouldn't work if you wanted to offer up a plain text file for download (the browser would simply load it in the window) unless you placed in a zip file or tar archive.
    Paul Waring - Web site design and development.

  3. #3
    AO French Antique News Whore
    Join Date
    Aug 2001
    Posts
    2,126
    *look at the greenie that pwaring got for answering such a easy answer*
    -Simon \"SDK\"

  4. #4
    AO Antique pwaring's Avatar
    Join Date
    Aug 2001
    Posts
    1,409
    Originally posted here by SDK
    *look at the greenie that pwaring got for answering such a easy answer*
    It's only easy if you know the answer.
    Paul Waring - Web site design and development.

  5. #5
    rebmeM roineS enilnOitnA steve.milner's Avatar
    Join Date
    Jul 2003
    Posts
    1,018
    Originally posted here by SDK
    *look at the greenie that pwaring got for answering such a easy answer*
    And the greenie didn't even come from me....

    Until now.

    Thanks pwaring - that's a huge help.

    Steve
    IT, e-commerce, Retail, Programme & Project Management, EPoS, Supply Chain and Logistic Services. Yorkshire. http://www.bigi.uk.com

Posting Permissions

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