Upload File with one button

后端 未结 2 1989
萌比男神i
萌比男神i 2021-02-08 07:11

How can I make a button in the html you need to send files that allow you to select the file and then sending it on the page that I want without using a button to select the fil

相关标签:
2条回答
  • 2021-02-08 07:57

    You should use

    HTML

    <form id="form">
     <input type="file" id=file"/> 
    </form>
    

    more info: http://www.w3.org/wiki/HTML/Elements/input/file

    Jquery

    $("#file").onchange(function () {
     $("#form").submit();
    });
    
    0 讨论(0)
  • 2021-02-08 07:59
    <form>
        <input type="file" onchange="this.form.submit()" /> 
    </form>
    
    • jsFiddle Demo
    • form.submit() on MDN
    0 讨论(0)
提交回复
热议问题