I would like to know how I to save my div image to database. I already know that I cannot save the actual image into database, I have to save the name of the image and link it to a folder called images. I can take the image of the div that is not the problem the problem is how do I save the image to a folder and link the name to database I know how to do it with regular images i just dont know how to do it with div as image. im using mysqli code for php i don't know if that matters. here is my code i need to save the image that was created with a unique name.
$(document).ready(function(){
var element = $("#firstshirt"); // global variable
var getCanvas; // global variable
$("#btn-Preview-Image").on('click', function () {
html2canvas(element, {
onrendered: function (canvas) {
$("#previewImage").append(canvas);
getCanvas = canvas;
}
});
});
$("#btn-Convert-Html2Image").on('click', function () {
var imgageData = getCanvas.toDataURL("image/png");
// Now browser starts downloading it instead of just showing it
var newData = imgageData.replace(/^data:image\/png/, "data:application/octet-stream");
$("#btn-Convert-Html2Image").attr("download", "your_pic_name.png").attr("href", newData);
});
});
<input id="btn-Preview-Image" type="button" value="Preview"/>
<a id="btn-Convert-Html2Image" href="#">Download</a>