Am trying to trigger an upload box (browse button) using jQuery.
The method I have tried now is:
$(\'#fileinput\').trigger(\'click\');
Just for the sake of curiosity, you can do something like you want by dynamically creating an upload form and input file, without adding it to the DOM tree:
$('.your-button').on('click', function() {
var uploadForm = document.createElement('form');
var fileInput = uploadForm.appendChild(document.createElement('input'));
fileInput.type = 'file';
fileInput.name = 'images';
fileInput.multiple = true;
fileInput.click();
});
No need to add the uploadForm to the DOM.