You know how a file selection browser popup opens when you click on an HTML input element with type file
? Can I trigger that popup to appear in javascript?
At a certain point in my javascript, I'd like for the popup to appear so that user can upload a text file. Then, I plan to turn the file blob data into an arraybuffer with the HTML5 FileReader API.
I've tried triggering the popup by faking a click to a file input element to no avail:
// Does not work.
var input = document.createElement('input');
input.type = 'file';
input.click();
How can I write a javascript function to trigger the file selection popup? I know that I can instead rely on an HTML5 drag and drop interface for uploading files, but I prefer the popup.