View Full Version : download

10-06-2009, 04:04 PM
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.

10-07-2009, 01:07 AM
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.