Am trying to trigger an upload box (browse button) using jQuery.
The method I have tried now is:
$(\'#fileinput\').trigger(\'click\');
I think i understand your problem, because i have a similar.
So the tag have the atribute for, you can use this atribute to link your input with type="file".
But if you don't want to activate this using this label because some rule of your layout, you can do like this.
$(document).ready(function(){
var reference = $(document).find("#main");
reference.find(".js-btn-upload").attr({
formenctype: 'multipart/form-data'
});
reference.find(".js-btn-upload").click(function(){
reference.find("label").trigger("click");
});
});
.hide{
overflow: hidden;
visibility: hidden;
/*Style for hide the elements, don't put the element "out" of the screen*/
}
.btn{
/*button style*/
}
Of course you will adapt this for your own purpose and layout, but that's the more easily way i know to make it work!!