0

I'm using PHP and my script outputs a list of links for files that can be downloaded by the user. To download each file, as a user I would have to copy the url and paste it into something like Free Download Manager.

I would like to improve the user experience and have a "Download" button that would handle or initiate the download process.

I'm thinking either have code written in PHP to act as a download manager, or tie the "Download" button to the functionality of a firefox or such add-on that act as a download manager. Does anyone have good suggestions for the sort of thing I'm trying to do?


Update:

Let's say that: - my script presents the user with a list of files that can be downloaded. - next to each file, there's a checkbox, then at the bottom a button that says "download selected".

If this is the setup I have, if I use force download, then clicking the "download selected" button will force dl 12 files at the same time, so not exactly like a download manager. I'm thinking this probably requires something that takes both PHP and Firefox behavior into account.

sameold
  • 18,400
  • 21
  • 63
  • 87
  • Unless a specific download manager implements a concrete download list format, there's no way to automate a "list of urls to download" mechanism. – mario Jun 04 '11 at 16:48
  • @mario, Can you tell me more. Also read my updated question. – sameold Jun 04 '11 at 17:04
  • Not possible. MIME allows for multipart/ payloads and external url entities, but not for HTTP clients. At best you could pop up multiple iframes (or a JS Location:/Refresh: chain) and force 12 download dialogs at once. That's not very reliable and user-friendly. So unless you *already have* decided on a workable Firefox download extension which provides an option for that, not possible. – mario Jun 04 '11 at 17:10

1 Answers1

0

You can use php header() to force download for single file per time and multiple times.

Some links for you to reference from.

Another good example from php.net: readfile()

  • careful with IE, it disrespects the Content-Type header in up to IE7, and also in IE8 when in quirks mode. – damianb Jun 04 '11 at 16:48
  • I don't know about this, do you have any sources related to this? –  Jun 04 '11 at 16:55
  • http://www.howtocreate.co.uk/wrongWithIE/?chapter=Content-type%3A+text%2Fplain here's one. Try it in the older versions of IE. There's another one about it (it actually led to security issues), lemme dig it up. – damianb Jun 04 '11 at 16:58
  • @BeingSimpler: here's the other link: http://blog.phpbb.com/2008/10/25/attachment-headaches-with-the-internet-explorer/ - you had to actually set a header to tell IE to behave properly with Content-Type in IE8 still, even. Ugh. – damianb Jun 04 '11 at 16:59
  • @BeingSimpler, But let's say that my script presents the user with a list of files that can be downloaded. Next to each file, there's a checkbox, then at the bottom a button that says "download selected". If this is the setup I have, and I use your suggestion, then clicking the "download selected" button will force dl 12 files at the same time, so not exactly like a download manager. I'm thinking this probably requires something that takes both PHP and Firefox behavior into account. – sameold Jun 04 '11 at 17:03
  • So you are talking about download manager (this could be browser's add-on rather than web app itself). I think it isn't so related to PHP since PHP can only handle one-by-one downloads, or this is out of my knowledge range. I know there is a Java Applet that helps users download multiple files called myDownloader: http://www.hotscripts.com/category/php/scripts-programs/file-manipulation/download-systems/ –  Jun 04 '11 at 17:22