open file upload dialog on click

file-upload, html, javascript, jquery

Solution

Tested today the simple code given in the question and the situation has changed:

- IE9: works

- Chrome23: works

- Firefox15: works

There is just one catch - on IE the .click() is a blocking operation while on other browsers it is not.

Problem

I have to open file upload dialog by clicking some other button i.e i am hiding file upload control(visibility:hidden) and on clicking of some other button i want to open that dialog. Below is the code which i am having: ``` <input type="file" style="visibility: hidden;" /> ``` Below is the javascript: ``` $('#button').click(function() { $('input[type=file]').click(); }); ``` It is working fine in Firefox 4 and IE8 but in chrome12 it is not working i.e the dialog is not being opened. Any idea why?

Original source