Am trying to trigger an upload box (browse button) using jQuery.
The method I have tried now is:
$(\'#fileinput\').trigger(\'click\');
I have it working (=tested) in IE8+, recent FF and chrome:
$('#uploadInput').focus().trigger('click');
The key is focusing before firing the click (otherwise chrome ignores it).
Note: you do NEED to have your input displayed and visible (as in, not display:none
and not visibility:hidden
).
I suggest (as many other have before) to absolutely position the input and throw it off screen.
#uploadInput {
position: absolute;
left: -9999px;
}