If you're facing issues with Safari or older versions of IE when trying to trigger the file input element even if it's hidden using display:none, there are alternative solutions that can work universally.
One workaround is to set the positioning of the element to fixed and then position it off-screen by using right: 100% / bottom: 100%.
Check out an example here
input[type="file"] {
position: fixed;
right: 100%;
bottom: 100%;
}
Another approach is to utilize CSS commonly used for visually hiding content but keeping it accessible for screen readers:
Here's an example demonstrating this method
input[type="file"] {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0,0,0,0);
border: 0;
}
Both of these approaches effectively hide the input element without relying on display:none.