'Javascript download: detect rename of file
If I use some code like this, to start a Download with Javascript in my browser:
const link = document.createElement("a");
link.style.display = "none";
link.href = URL.createObjectURL(file);
link.download = file.name;
document.body.appendChild(link);
link.click();
Do I have any way to understand if the file has been renamed during download? I mean: if I download two times the file test.txt, the second one is renamed in something like test(1).txt.
Any chance to detect this change in the script?
Thanks!
Solution 1:[1]
These no way to detect the filename change.
if u want avoid the duplicated download (file name duplicated) from the same page as alternative solution u can create on an array to store previous filename
Solution 2:[2]
No.
There is no API that would provide that information.
Solution 3:[3]
Renaming gets done by the browser automatically if there already is a file with the same name. Therefore no.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | WolfCode |
| Solution 2 | |
| Solution 3 | GabeRAMturn |
