I have the following code:
<p onclick="jQuery('#file').click()">Select a file</p>
<input type="file" id="file" name="file" />
When the user clicks on "Select a file", it's also supposed to open the file browser like when you press on the "Browse" button generated by <input type="file" />
, where the user can select a file.
It works fine in Chrome and IE7. How do I make it work in Firefox?
Trust me, I went to trouble already about that. It will not work on Firefox and I did not find an answer as to how to make it work.
I suspected you are trying to customize the looks of your input file. I suggest, you use opacity. Set opacity of input file to zero, to make it not visible. Then put above it two span element above it. Then you could style the span as much as you like. When you click any of the span, the click on input file is also trigger.
added notes:
With that you have the power to change the look of input file. The problem is, opacity won't work on IE6. ;)
There is a better way to open the dialog (it works across all modern browsers at this time). Just change
jQuery('#file').click();
to
jQuery('#file').trigger('click');
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