0

How can I detect the action when clicking on the browse on this form?

<form action='#' enctype='multipart/form-data'>
    <input type='file' name='file'>  
</form>

I have another div and when I click on that div I want that the browse action will happen

user4571629
  • 440
  • 3
  • 10
  • 24
  • 1
    Not as easy as it sounds, but quite doable, still a [duplicate](http://stackoverflow.com/questions/793014/jquery-trigger-file-input) – adeneo Jan 05 '16 at 19:19
  • 3
    http://stackoverflow.com/questions/26878854/open-file-dialog-when-input-type-button, http://stackoverflow.com/questions/19310450/click-on-input-box-to-show-open-file-dialog-but-not-click-on-choose-file-button – adeneo Jan 05 '16 at 19:20
  • Thank you, one of the answers below got me to the solution! – user4571629 Jan 05 '16 at 19:23

2 Answers2

0

check this fiddle, it is as simple as

$( "#file" ).click( function(){

   alert(1);

} );
gurvinder372
  • 66,980
  • 10
  • 72
  • 94
0

OK, I figured it out: When clicking on the div that I want to trigger it for example #my_div, The input class will be clicked

$("#my_div").click(function() {
    $("input_class").click();
})
user4571629
  • 440
  • 3
  • 10
  • 24