I have following simple code for downloading file.
let text = 'download'
function make(){
const data = new Blob([text],{ type: 'type: "text/plain"' })
document.querySelector('a').download = 'untitle'
document.querySelector('a').href = window.URL.createObjectURL(data);
}
make()
<a download>Download</a>
Broswer (in chrome not sure about other broswer) will automatically specify the number for the second or more time of downloading a same name file.
Example:
first time download: untitle.text
second time download: untitle(1).text ......
Is it possible to prevent the browswer of this behavior from happening ?
Thanks
You could try in https://jsfiddle.net/yapb2xus/1/
You just can't, that's the default behavior for most of the browsers and almost all OSes because you can't have two files with the same name.
Since chrome (and firefix I think) automatically save the file in a default path, in the first time the file untitle.text will not exist and will be saved with original name. At second tryz the file will exist on default download path, so the browser automatically add a sufix to it.
What you can try is to create your own sequence, adding a timestamp or something else to the name at every click on the link.