Failed to click input type = "file" in Safari browser for windows

Here is my html code

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

here is the jquery code

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

It works as expected in Chrome, but does nothing on windows safari. And I did not check the error in the console. Here is jsfiddle

+3
source share
2 answers

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

  opacity:0;width:0px;height:0px; 
+12
source

You can also do:

 input[type="file"] { visibility: hidden; position: absolute; } 
+1
source

Source: https://habr.com/ru/post/1208793/


All Articles