Input file type open when loading page

Asked

Viewed 86 times

0

I have the following input:

<input type="file" accept="image/*" capture="camera" style="display:none" id="capturar">

I would like when loading the page to already open the field to select the file.
I tried the following, in jquery:

$(document).ready(function(e) {
    $("#capturar").click();
}); 

But without result.
Some help ?

  • Have you tried replacing it with $("#capturar").trigger('click'); ? In some [browser] specific versions .click() doesn’t work.

  • Yes, even so does not open the field to select the file

  • @Stone for safety is unlikely, probably impossible, what you’re asking, which in case is to activate a input type="file" without the click event.

  • 1

    Here has several answers explaining why you won’t be able to do this!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.