Download Multiple files in one HTTP request
Solution 1
It is possible to send a multipart response in HTTP:
In general, HTTP treats a multipart message-body no differently than any other media type: strictly as payload. […] an HTTP user agent SHOULD follow the same or similar behavior as a MIME user agent would upon receipt of a multipart type.
[…] If an application receives an unrecognized multipart subtype, the application MUST treat it as being equivalent to "multipart/mixed".
But since Firefox is the only browser that I know about to support such multipart responses (apart from multipart/byterange), you should use some archive file format for this purpose.
Solution 2
That is practically not usable due to poor browser support. You can pack them into a tar or zip file at server side and serve the archive file though.
Solution 3
I think it's not possible since each HTTP request has only one URI.
Solution 4
You can zip the file with PHP, serverside, and request the file or return it from within your script by setting the appropriate headers, see ZipArchive
class
Or you create a special client that can parse your then self-specified message format (a flash app, a plugin) - but if your client is simply your browser you'll get one response with a fixed content-length from the server.
Comments
-
bogha almost 2 years
how is it possible to download multiple files in one HTTP request? what i mean it's like when you have multiple attachments and you select what you want to download then press download so they will be automaticcaly downloaded and you don't have to click on each one manually.
i'm using PHP as a serverside srcipting.
-
Alan Plum about 14 yearsCorrect. HTTP requests have a specific start and end. You could probably abuse the protocol by writing a special client and serving the files as one file (much like a
tar
file or just a MIMEmultipart
), but then we wouldn't be talking about a pure HTTP solution that works across all browsers anymore. -
Gumbo about 14 yearsIt is practically possible (Firefox proves it). But it is practically not useful since it’s only Firefox that supports it.
-
Ekin Koc about 14 yearsMore clarification then :) BTW, since browser developers are leaning against more public stuff like html5 elements and CSS3, I doubt that we will see a widespread adoption of this anytime soon. Good to see that FF implemented it though.
-
Yaroslav almost 10 yearsIt's not possible in that way, because if you'll send location header download will not start and browser will be redirected, otherwise if file will be downloaded no any redirect will be done.