[http] Download multiple files with a single action

I am not sure if this is possible using standard web technologies.

I want the user to be able to download multiple files in a single action. That is click check boxes next to the files, and then get all the files that were checked.

Is it possible - if so what basic strategy do you recommend. I know I can use comets technology to create server side events that trigger an HttpResponse but I am hoping there is a simpler way.

This question is related to http web-applications download

The answer is


_x000D_
_x000D_
var links = [_x000D_
  'https://s3.amazonaws.com/Minecraft.Download/launcher/Minecraft.exe',_x000D_
  'https://s3.amazonaws.com/Minecraft.Download/launcher/Minecraft.dmg',_x000D_
  'https://s3.amazonaws.com/Minecraft.Download/launcher/Minecraft.jar'_x000D_
];_x000D_
_x000D_
function downloadAll(urls) {_x000D_
  var link = document.createElement('a');_x000D_
_x000D_
  link.setAttribute('download', null);_x000D_
  link.style.display = 'none';_x000D_
_x000D_
  document.body.appendChild(link);_x000D_
_x000D_
  for (var i = 0; i < urls.length; i++) {_x000D_
    link.setAttribute('href', urls[i]);_x000D_
    link.click();_x000D_
  }_x000D_
_x000D_
  document.body.removeChild(link);_x000D_
}
_x000D_
<button onclick="downloadAll(window.links)">Test me!</button>
_x000D_
_x000D_
_x000D_


Similar questions with http tag:

Similar questions with web-applications tag:

Similar questions with download tag: