There is no API for the input modal file. Also, if the user closes the browser, will your code no longer run?
Of course, there is a window.onunload method that allows you to define the example you are giving.
In the comments, the best I can think of would be useful, since if nothing is selected, file.value.length
will be 0
.
source share