Am trying to trigger an upload box (browse button) using jQuery. The method I have tried now is:
$('#fileinput').trigger('click');
But it doesn't seem to work. Please help. Thank you.
This is due to a security restriction.
I found out that the security restriction is only when the <input type="file"/> is set to display:none; or is visbilty:hidden.
<input type="file"/>
display:none;
visbilty:hidden
So i tried positioning it outside the viewport by setting position:absolute and top:-100px; and voilà it works.
position:absolute
top:-100px;
see http://jsfiddle.net/DSARd/1/
call it a hack.
Hope that works for you.
1.4m articles
1.4m replys
5 comments
57.0k users