I have a hidden file input element. Is it possible to trigger its select file dialog box from a button's click event?
If you're looking to have your own button to upload a file instead of using <input type="file" />
, you can do something like:
<input id="myInput" type="file" style="visibility:hidden" /> <input type="button" value="Show Dialog" onclick="$('#myInput').click();" />
Note that I used visibility: hidden
, instead of display: none
. You cannot call the click event on a non-displayed file input.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With