Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
6
rated 0 times [  8] [ 2]  / answers: 1 / hits: 132409  / 13 Years ago, wed, december 21, 2011, 12:00:00

I have a hidden file input element. Is it possible to trigger its select file dialog box from a button's click event?


More From » jquery

 Answers
50

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.


[#88436] Tuesday, December 20, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
denis

Total Points: 260
Total Questions: 87
Total Answers: 87

Location: Venezuela
Member since Thu, Jul 15, 2021
3 Years ago
;