How Can I Save A Dynamically Generated Image To My Database?
I have an HTML page that captures a user's signature as an SVG. I convert it on the page to a .png and put it into an image container. How can I utilize this to go into a database?
Solution 1:
Save the image as a file. Store the file path in your database.
Léon
Solution 2:
If you are talking about the image itself, look up BLOBs (they stand for Binary Large Objects). They are the way to store large binary data in a database.
If you are talking about the tags, you'd store them like you would any other text.
Solution 3:
Supposing that you only need to save the path to the image (your image is stored in the server or you are using it from the internet.)
$("#save").click(function(){
var datapair = sigdiv.jSignature("getData", "svg");
var i = new Image();
i.src = "data:" + datapair[0] + "," + datapair[1];
$(i).appendTo($("#outputSvg"));
var canvas = document.getElementById("canvas");
canvg(canvas, datapair[1]);
var img = canvas.toDataURL("image/png");
$("#outputRaster").append("<img src='"+img+"'/>");
imageTag = "<img src='"+img+"'/>";
//$.ajax( {url : yourUrl , data: imageTag} );
});
if you need to upload image using jQuery you car read this article : link
Post a Comment for "How Can I Save A Dynamically Generated Image To My Database?"