jQuery trigger file input

后端 未结 21 1614
梦如初夏
梦如初夏 2020-11-22 08:49

Am trying to trigger an upload box (browse button) using jQuery.
The method I have tried now is:

$(\'#fileinput\').trigger(\'click\');   
21条回答
  •  旧时难觅i
    2020-11-22 09:00

    You can click the input file from your JQuery while keeping it hidden fully.

    I am using this:

    < input type="file" name="article_input_file" id="article_input_file" accept=".xlsx,.xls" style="display: none" >
    
    $("#article_input_file").click();
    

    this works from within any standard script tag in your HTML page.

提交回复
热议问题