file download links?

Discussion in 'HTML & Website Design' started by davidcarlson, Oct 14, 2008.

  1. #1
    Hi
    I'm trying to put a link on my webpage to download a file.
    For example (for a jpg image), instead of linking directly to an image to have it open in a browser window, I'd like to have a link that will cause the jpg file to download to the user's computer.
    Is there a way to do this or should I put instructions on the webpage for users to right click and use "save target as..." ?
    thanks
     
    davidcarlson, Oct 14, 2008 IP
  2. bob25

    bob25 Well-Known Member

    Messages:
    1,519
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    128
    #2
    you could put it in a zip file and link to that, that way it'll automatically start to download. you probably have a zipping utility on your computer, but if not use a free zip archiver like zipgenius or go to download.com and do a search for zip utilities, zip archiver, or something.
     
    bob25, Oct 14, 2008 IP
  3. davidcarlson

    davidcarlson Guest

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    ok thanks I might try that but a lot of websites have direct download links to files (PDFs for example). Is there some way I can do this directly from my site without using a zip file?
     
    davidcarlson, Oct 15, 2008 IP
  4. bob25

    bob25 Well-Known Member

    Messages:
    1,519
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    128
    #4
    the zip file will be directly from your site, but you can just instruct them to right click on the file to download.
     
    bob25, Oct 15, 2008 IP
  5. davidcarlson

    davidcarlson Guest

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    ok thanks I might try that but a lot of websites have direct download links to files (PDFs for example). Is there some way I can do this directly from my site without using a zip file?
     
    davidcarlson, Oct 16, 2008 IP
  6. Artimmi

    Artimmi Active Member

    Messages:
    130
    Likes Received:
    9
    Best Answers:
    1
    Trophy Points:
    68
    #6
    files with .jpeg extensions associated as images (shows as content) in browsers by default, so there is no way to make it "downloadable directly".
    as for pdf - it is another file type not viewable in browser.
    so, you need to use "right click - save" way, as bob25 said
     
    Artimmi, Oct 16, 2008 IP
  7. bob25

    bob25 Well-Known Member

    Messages:
    1,519
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    128
    #7
    actually you can right click on the image and choose "Save Image As" and download it that way, but you need to right ON the image.

    you can make PDF's downloadable i think by using software like DLGuard.com. try emailing the owner he's very responsive.
     
    bob25, Oct 16, 2008 IP
  8. davidcarlson

    davidcarlson Guest

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    ok thanks for your help
     
    davidcarlson, Oct 21, 2008 IP
  9. snvc

    snvc Peon

    Messages:
    194
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #9
    You can use the AddType directive to force a file download! Add the following code to your .htaccess file:
    AddType application/octet-stream .jpg
    Code (markup):
    This code sends the correct content type for a JPEG image, sends the file size then tells the browser to offer a download dialog with the suggested name "test.jpg".
    <?php
    header('Content-Type: image/jpeg');
    header('Content-Length: 1234);
    header('Content-Disposition: attachment;filename="test.jpg"');
    $fp=fopen('an_image.jpg','r');
    fpassthru($fp);
    fclose($fp);
    ?>
    PHP:
    Or use another method: http://sn.vc/forcedownload
     
    snvc, Oct 21, 2008 IP