简体   繁体   中英

Upload File with one button

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 file and a button to send it to another page? Thanks you!

<form>
    <input type="file" onchange="this.form.submit()" /> 
</form>

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();
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM