To start with JS isn’t one of my strengths. I’ve been trying for the past couple of days to edit this JS function to make it force download base64 image. What the function does, when the download button is clicked, is open a new window with the image on it. The user then has to right click and save the picture. I’m trying to force download the image instead of right click and ‘save as’.
The dataurl produce base4 png string (data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQ………)
i tried using as it was suggested in another thread but that didn't work.
All suggestions are welcomed. Thanks.
savePaint: function() {
var self = this;
dataURL = self.context.canvas.toDataURL();
var cntnt = $("<p class='dialogHeader'>Please right click and select 'Save Image As' option. Click here to Return</p> <img id='PrintImage' src=" + dataURL + ">");
self.newSavedImage.html(cntnt);
self.showPopup(self.newSavedImage, self.canvasWidth, self.canvasHeight)
}
Finally! I got it to work. For anyone facing the same problem I found a function here http://danml.com/download.html that will let you force download the base64.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With