Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

event for file upload cancel in javascript

We can use file.onchange if we gonna set an event callback for file reading using javascript, but how to set event for when user cancel the upload (close the browse panel)?

like image 885
stack underflow Avatar asked Jul 13 '12 01:07

stack underflow


Video Answer


1 Answers

There is no API for the file input modal. Besides, if the user closes the browser your code won't be running anymore, will it?

Of course there is the window.onunload method which allows you to detect the example you give.

Per the comments, the best thing I can come up with that would be helpful is that if nothing is selected, file.value.length will be 0.

like image 131
Jon Jaques Avatar answered Sep 23 '22 16:09

Jon Jaques