Now that I have finished saving the image to the local, but the browser is saved to the default folder, how do I modify the code to save to the specified folder?
function download(canvas,type) {
var imgdata = canvas.toDataURL(type);
var fixtype = function (type) {
type = type.toLocaleLowerCase().replace(/jpg/i, 'jpeg');
var r = type.match(/png|jpeg|bmp|gif/)[0];
return 'image/' + r;
};
imgdata = imgdata.replace(fixtype(type), 'image/octet-stream')
var saveFile = function (data, filename) {
var link = document.createElement('a');
link.href = data;
link.download = filename;
var event = document.createEvent('MouseEvents');
event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
link.dispatchEvent(event);
};
saveImageCount++;
var str = "" +saveImageCount;
var pad = "0000";
var ans = pad.substring(0, pad.length - str.length) + str;
var filename = ans + '.' + type;
saveFile(imgdata, filename);
}