Download generated image

0

I want to put on my site the option of downloading some data from a form as an image. In my current code I transform the content into image, but it is printed in HTML.

Here is the simplified code in JsFiddle: link

All I need now is for this generated image to be automatically downloaded by clicking on "GENERATE", and it will not appear in html!

Can you help me?

    
asked by anonymous 29.10.2018 / 19:24

1 answer

1

Using jquery to create and add the element in DOM I added the following code to your script and the test worked, maybe that would help.

a = $("<a>").attr({href:dataUrl,download:'image.jpeg'}).html("OLA");
$("body").append(a);
a.get(0).click();

link

    
29.10.2018 / 19:48