0

I have input[type=file] with log-in form on it. So after user logged in - file upload dialog instantly opened.

In all browsers I need (FF, IE10+) except Google Chrome, this call works perfect:

$('input[type=file]').click();

or

$('input[type=file]')[0].click();

or

$('input[type=file]').trigger('click');

Did anyone met this problem? If so, how to achieve this on Chrome?

Edit1: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement.click here in support it's said that I can use it on input[type=file]. Also this click is working, but only if I'll actually click something, that than is clicking my input(so only after physical click).

Edit2: And yes, I've already tried search function. But everything I've found was old, and pretty much anyone told, that even FF is not supporting this (which is not true now).

Edit3: Example test page: http://jsfiddle.net/Ux3t4/

3
  • 1
    It would not be supported in chrome. due to security issues. Support in other browsers may be termed as bug and I don't think any solution will be cross browser ever. Commented Jun 11, 2014 at 11:43
  • 1
    FF v30.0 not working. How it worked for you? Commented Jun 11, 2014 at 11:44
  • Currently FF29, it it doesn't want to update for some reason up to 30... Commented Jun 11, 2014 at 11:59

1 Answer 1

1

This is not allowed due to security reasons. By the way, even in Internet Explorer (the dialog will be shown but once you select a file, the file won't be submitted).

Sign up to request clarification or add additional context in comments.

3 Comments

Maybe it's not allowed for Chrome only? Because this works perfect on both FF and IE. Just tried, and all of my files were submited correctly.
@Kamilius FF trigger popup blocker you need to manually allow the popup.
@Kamilius As far I remember you can't do this. I searched for a solution on Google and found some useful info there: stackoverflow.com/questions/4878164/input-file-click-chrome

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.