|
|
|
|
|
by megous
2865 days ago
|
|
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. |
|
You’ve just replaced them with stupid DOM hacks.