0

When download is added to <a> tag, user can download a file when clicking the link instead of transitioning to the URL.

<a href="http://www.example.com/index.html" download>Download</a>

But is there a way to do bulk download (multiple files)? Thanks in advance!

Dave
  • 405
  • 4
  • 17
  • 1
    https://en.wikipedia.org/wiki/ZIP_(file_format) – Phil Apr 07 '22 at 00:44
  • What do you mean by bulk download files? Won't clicking multiple links suffice? What have you tried before that didn't work? – ThatXliner Apr 07 '22 at 00:44
  • @Phil There are people who don't know how to unzip. So I'd rather have a few files downloaded than one zip file. – Dave Apr 07 '22 at 00:46
  • @ThatXliner It's cumbersome to manually click two different links when you obviously need both. – Dave Apr 07 '22 at 00:47
  • 2
    The answer is no. This is not something that any browser supports in any way, shape or form – Phil Apr 07 '22 at 00:49
  • In that case, does this help? https://stackoverflow.com/questions/18451856/how-can-i-let-a-user-download-multiple-files-when-a-button-is-clicked – ThatXliner Apr 07 '22 at 00:50
  • Try telling Windows users it (a xip file) is a "Microsoft compressed folder". – traktor Apr 07 '22 at 00:54
  • You can write a web extension/add-on to do this. I don't like promoting my work on here too much but if you wanted to see how something like that might work give me a shout https://chat.stackoverflow.com/users/5091644 @Dave – Andy Apr 07 '22 at 01:02

1 Answers1

1

There is no way to download multiple files through pure HTML. You could perhaps use javascript to download these files:

var links = ['file1.pdf', 'file2.jpg'] // Change with file paths

for (let filename in links) {
   var element = document.createElement('a');
   element.setAttribute('href', '/'+links[filename]);

   // Change 'file' to something else to change the name of the downloaded file
   element.setAttribute('download', 'file');

   // Optionally, hide the element before appending, so that the user doesn't download the file again.
   document.body.appendChild(element)
   element.click() // This will prompt the user to download
}

   
Quantalabs
  • 379
  • 2
  • 14