0

I need to open the File picker dialog in javascript which i can do using the following

var uploadInput = document.createElement("input");
uploadInput.type = 'file';
uploadInput.accept = '.json,application/json';
console.log('preclick');
uploadInput.click();
console.log('postclick');

I need a way to check if a file has been picked or not. I can use the onchange event to detect when a file is picked, but i haven't been able to detect if you just close the dialog.

So the question is there some way to detect when the file picker dialog is closed? This needs to work in Chrome.

Note: IE11 and Edge seems to block on uploadInput.click(); so there i don't have a problem.

Peter
  • 37,042
  • 39
  • 142
  • 198
  • 1
    please look over here http://jsfiddle.net/Shiboe/yuK3r/6/ – Gardezi Sep 13 '17 at 14:59
  • @Gardezi it looks like you just copied the answer from https://stackoverflow.com/a/15738200/58553 that is ok but you should give some cred to the initial poster... – Peter Sep 14 '17 at 08:16
  • @Peter Nope, I did not copy it from this answer the one you pointed. This URL was given in some blog. So I copied the link and pasted it over here. – Gardezi Sep 14 '17 at 08:36

0 Answers0