I am trying to take the following form and convert it to use XMLHttp. Cannot get a working example of how to convert this to use XMLHttp.
<form enctype='multipart/form-data' action='process.do'>
<input id='myfile' type='file'>
<input type='hidden' name='systemid' value='a1312423r1rde223e423e'>
<input type='hidden' name='systemname' value='My value'>
</form>
var x = new XMLHttpRequest()
x.open('POST', 'process.do');
// Where to add systemid, systemname parameters?
x.send($('myfile').files[0])
Just send()
a FormData object instantiated from the form object.
var x = new XMLHttpRequest()
x.open('POST', 'process.do');
x.send(new FormData(document.querySelector("form")));
That will include all the data from the form.
You'll need to give your file input a name
though.
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.