I am trying to make a downloadable file from only a dataURL and I am not sure why it is not working. I am reading the dataURL from a file and inserting its dataURL into an with the download attribute. but when i generate de click the page goes blank and says it can´t find the page. Here is how I am trying to do it.
reader.readAsDataURL(file);
reader.onload = function (evt) {
var element = document.createElement('a');
element.setAttribute('href', evt.target.result);
var name=filename.split(".");
element.setAttribute('download', 'filename');
element.style.display = 'inline-block';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
From the code above I obtain this
How can I properly make a download action for the dataURL?