how to make more than one file available for download with just one HTML button

Asked

Viewed 51 times

-2

I wonder if in HTML it is possible to download more than one file (photo in case) I am using the bootstrap button and I made the following code :

<a class="btn btn-primary" href="images/cant3.png" download="cant3.png" ; >Baixe nosso Cardápio Físico</a>

but I wish that when clicking was made the download of 2 images, someone can help me??

1 answer

0


I think the best solution in the case of a menu is to join the two images in one. Consider making a pdf.

There is a solution that may not be as elegant, but as I already solved a similar problem so I will post, and if someone put a more "elegant" answer consider it.

You can put another download to be done together with Javascript.

function dowload(){
  document.getElementById('btn_imagem2').click();
}
<a class="btn btn-primary" href="images/cant3.png" download="cant3.png" onclick="dowload()">Baixe nosso Cardápio Físico</a>
<!--Aqui é a segunda imagem que pretende fazer o dowload-->
<a id="btn_imagem2" class="btn btn-primary" href="images/cant4.png" download="cant4.png" hidden="true">Baixe nosso Cardápio Físico</a>

So when the user clicks on button 1, you force him to click button 2, which he is not even seeing (notice the property Hidden="true"). this will make the two download event be fired.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.