In my JavaScript, I'm using an <a>
tag with the download attribute to let the user download a generated file. I can set a default name for the file, however the user might change it before they save it to their system. Is there a way I can get the name that the user wrote in the save dialog?
The main reason for this is so that I can use the same name again as the default when the user goes to download the file again.
Here's the code:
var json = JSON.stringify(currentProject, null, '\t');
var a = document.createElement('a');
a.href = URL.createObjectURL(new Blob([json], {type: 'text/json'}));
a.download = currentProjectName;
a.click();
If it isn't possible to do this with the <a>
tag method, I would like to know of some other download method that allowed for this, in some way.