Results 1 to 2 of 2

Thread: download

  1. #1
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default download

    hi, i want to create a page with many urls in it. but when you click on them, they start to download file to their computer. what php i have to write? because if there is a picture and i use HREF explorer opens it in his window, but i need to download. thanks.

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

    Default

    You are looking for a "force download" script, and you can google that for options.

    However, there is no way to actually force a download. There is no command for this.

    Browsers decide what to do with files-- your server just sends them the data when they request it.

    There are two things you can do:

    1. You can put the file in a .zip archive-- this forces a download (because it must be unzipped before use), but it requires an extra layer of file/work to use.

    2. You can attempt to change the headers for filetype so the browser doesn't do its normal behavior, but instead default to downloading it because it doesn't know what it's doing. But this is just a trick and will not work in some browsers and is really a cheap way to code. (Google "force download php headers" and see what you get if you really want to try this.)


    And of course you can just ask your visitors to "right click, save as" on the links.
    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

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
  •