SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to force a file download

    How to force a file download

    Is it possible to use ASP to create something like, the following webpage, where you click on the download Mozilla now and up pops the downloader.

    http://www.download.com/Mozilla-Fire...eatured.editor

    I need to make it so that I can download a .WMV video file. because giving users the direct link doesn't work and I think its alot better than asking them to right click and save item as..

    Does anyone have a script that I can use.

    Thanks in advance..
    Any help would be really appricated Thanks
    James
    Pope Online :: Web Design - http://www.popeonline.co.uk

  2. #2
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You could do this using a meta refresh tag like so:

    Code:
    <meta http-equiv="refresh" content="2;url=http://www.yoursite.com/filename.exe">
    So after 2 seconds the user is pushed to the exe which they will then be prompted to save.

  3. #3
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You could do this using a meta refresh tag like so:

    Code:
    <meta http-equiv="refresh" content="2;url=http://www.yoursite.com/filename.exe">
    So after 2 seconds the user is pushed to the exe which they will then be prompted to save.

  4. #4
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Thing View Post
    Code:
    <meta http-equiv="refresh" content="2;url=http://www.yoursite.com/filename.exe">
    This tries to download and open the .WMV file and this corrupts the file.

    I want it to download and then be opened by the user.

    but thanks for your ideas
    James
    Pope Online :: Web Design - http://www.popeonline.co.uk

  5. #5
    SitePoint Guru SSJ's Avatar
    Join Date
    Jan 2007
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can directly give a link to that exe file as follows:

    <a href="http://www.yoursite.com/filename.exe">Click Here To Download.</a>

  6. #6
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  7. #7
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thats how it is at the moment tho. And you don't get the option to download it. You are only allowed to run and open it. Which somehow corrupts it.

    I know the file is not corrupt because if you right click and save as it appears on the desktop with no problems whatsoever...

    Any Ideas

    JIM-bo
    Pope Online :: Web Design - http://www.popeonline.co.uk

  8. #8
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The key is the MIME type/contentType...if it's one that is playable by the browser or eg windows media player then you will get prompted to run the file. If it's set to something else eg application/octet-stream then you will get the SAVE AS dialog. that's what you have to change

  9. #9
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So are you saying that I have to change the file type from a .WMV to a .. Mpeg?
    Pope Online :: Web Design - http://www.popeonline.co.uk

  10. #10
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Look at the link I gave you, there is one line in the code that is

    Response.ContentType = "application/octet-stream"

    You're not doing anything to the file, you're simply telling the client that downloads it that "this file is an octet stream and it's NOT a WMV/video/mpeg whatever" - so that client opens the SAVE AS dialog box instead of the other thing.

  11. #11
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your help, I should be able to get that working now, I will let you know when I do.

    Cheers
    James
    Pope Online :: Web Design - http://www.popeonline.co.uk


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
  •