Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to click input type="file" in windows safari browser

Here is my html code

<input type="button" id="btn" value="UPLOAD" />
<input id="fileupload" type="file" style="display:none;" />

here is jquery code

 $('#btn').click(function () {
            $('#fileupload').click();
        });

It works as expected in Chrome and in windows safari doesn't do any thing.And i checked no error in console. Here is a jsfiddle

like image 691
iJade Avatar asked Dec 06 '25 03:12

iJade


2 Answers

try hiding input file using the below code instead of display:none;

 opacity:0;width:0px;height:0px;

You can also do:

input[type="file"] {
    visibility: hidden;
    position: absolute;
}
like image 37
thirdtiu Avatar answered Dec 08 '25 17:12

thirdtiu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!