1

I know I have seen websites that have allowed me to download multiple files at the same time. I clicked a link, got a warning that multiple files are coming my way, and then selected a folder where to place them all. Unfortunately I don't remember any specific sites anymore.

Now I'd like to add this feature to a website I'm developing myself, but I cannot find how to do it. Even searching google and here on SO yields nothing (or maybe I haven't figured out the right keywords).

So - anyone know how is this done? I know that it DIDN'T involve any custom plugins to the browser.

Added: A colleague showed me one such site, here's a screenshot:

Example

Although this gave me multiple Save-as dialog boxes, it's still better than nothing. Also in the developer tools I saw that it downloaded the files first via the Fetch API and then somehow made the Save-as dialogs appear via Javascript.

Anyone knows how this is done?

Vilx-
  • 104,512
  • 87
  • 279
  • 422
  • Does this answer your question? [How can I let a user download multiple files when a button is clicked?](https://stackoverflow.com/questions/18451856/how-can-i-let-a-user-download-multiple-files-when-a-button-is-clicked) – StackedQ Mar 18 '20 at 12:48
  • @Qiarash I doubt it. It wasn't a ZIP file and I wasn't presented with 100 "Save as..." windows. It was a single download of multiple files. Unless Chrome somehow detects the multiple `window.open()` calls and aggregates them? – Vilx- Mar 18 '20 at 12:50
  • second part of that answer will work for you. – StackedQ Mar 18 '20 at 12:51
  • @Qiarash Which one do you mean? I've read them all, and the answers come in 5 flavors: 1 - zip file; 2 - multiple calls to `window.open()`; 3 - multiple calls to `link.click()`; 4 - multiple calls to `iframe.src=...`; 5 - multiple calls to `window.location=...`. Now, admittedly, I haven't tried any of them, but as far as I can tell, they should all give me multiple "Save as..." prompts (except for the .zip file, of course). – Vilx- Mar 18 '20 at 12:55
  • try window.open() – StackedQ Mar 18 '20 at 13:03
  • @Qiarash Tried `window.open()` in a loop. First one opened, the rest were blocked as popups. I'm not using a separate popup blocker or whatever. This is vanilla Chrome. – Vilx- Mar 18 '20 at 14:31

0 Answers0