Download more than one file from server with one click (PHP, WAMP)
Just write the files on the server and send an archive like Gmail with a few attachments. Most modern operating systems should have no problem unpacking a package, some of them will do it on the fly (without having to do anything). I don't know PHP, but there seems to be a zip library, see examples on the PHP website .
source to share
This is not possible with PHP. You can only serve one file per request. However, you can call the browser to download multiple files with a little JavaScript:
var files = ['fileone.zip', 'filetwo.zip'];
for (var i = 0; i < files.length; i++){
window.open(files[i], 'Download file');
}
This is really quite frustrating. I would just go with the post.
PS. If you want to load html files using this method, you need to send a header Content-Disposition
for each file so that the document doesn't just appear in the popup spawned by window.open
:
header('Content-Disposition: attachment; filename="todownload.html"');
source to share