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.