Download the generated image

Asked

Viewed 60 times

0

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

Here the simplified code in Jsfiddle: https://jsfiddle.net/gor263yw/

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

can help me?

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 it helps you.

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

https://jsfiddle.net/gor263yw/3/

  • friend, thank you very much! works very well as I needed.

Browser other questions tagged

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