jQuery trigger file input

css, javascript, jquery

Solution

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`.

So i tried positioning it outside the viewport by setting `position:absolute` and `top:-100px;` and voilà it works.

see http://jsfiddle.net/DSARd/1/

call it a hack.

Hope that works for you.

Problem

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.

Original source

Related problems