问题
I am create a function to download the images into my localhost folder, but it cannot save it to the localhost folder, because I am using the localhost to create the function. Hope someone can guide me how to solve it the problem.
Below is my coding:
<input id="btn-Preview-Image" type="button" value="Download"/>
<script>
$(document).ready(function(){
var element = $("#html-content-holder"); // 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").trigger('click');
}
});
});
$("#btn-Convert-Html2Image").on('click', function () {
// 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);
const link = document.createElement('a');
link.download = 'your_pic_name.png';
link.href = getCanvas.toDataURL("./qr0601/images/image/png")
link.click();
});
});
</script>
The output like below the picture:
This is my working fiddle: https://jsfiddle.net/ason5861_cs/1a9mdf2t/
I need to save the file path is here C:\xampp\htdocs\qr0601\images. How to download the image save the location in the C:\xampp\htdocs\qr0601\images ?
来源:https://stackoverflow.com/questions/62149036/images-cannot-save-into-the-localhost-folder-location