You realize you don't need input field for file input in any of the modern browsers. Just capture the click event and create input field temporarily.
let i = document.createElement('input');
i.type = 'file';
// other attributes if you like
i.onselect = ev => {
// ev.files contains selected files
};
i.click();
i.remove();
No stupid styling hacks needed. At most you may need tabIndex on the <a> or <div> that represents the button for selecting files.
You can leave <input type=file> around if you want to submit data via <form> and not via XHR.
vinceguidry|7 years ago
megous|7 years ago
You can leave <input type=file> around if you want to submit data via <form> and not via XHR.
jandrese|7 years ago
baddox|7 years ago
iris-digital|7 years ago