Download more than one file from server with one click (PHP, WAMP)

I need to download multiple files from a server (PHP) with one click. one file could be downloaded, but it didn't work for multiple files at a time (assume the files are in diff directories). I am using WAMP, please help me.

thanks and greetings

tismon

+2


source to share


5 answers


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 .



+7


source


Not really sure what you are asking, if you are asking for a way to make the server serve multiple files to a user with a single request, then you probably need to go with a zip file or some other archive.



+5


source


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"');

      

+3


source


You can create an IFrame and in Javascript set the IFrame source to your various upload files. If you run into loading timing issues, you can try loading delay or using multiple IFrames (but the latter seems ugly).

+2


source


You can send the user an email with links or even an attachment if the file sizes are small.

+1


source







All Articles