我想知道如何才能完成这项工作。我有一个md5代码生成器,所以它可以为每个下载的图像提供唯一的名称但它似乎无法工作。
<script>
$(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(/^torcdesign.com:image\/png/, "data:application/octet-stream");
$("#btn-Convert-Html2Image").attr("download", "$confirm_coded").attr("href", newData);
});
});
</script>
<?PHP
$confirm_coded=md5(uniqid(rand())); ?>