<input id="name" name="name"/>
<input id="age" name="age"/>
<input id="file" type="file" name="file" multiple>
let forms = new FormData()
forms.append('name', document.getElementById('name').value)
forms.append('age', document.getElementById('age').value)
let files = document.getElementById('file').files
// 上传多个文件
Array.from(files).forEach(item => {
forms.append('file', item)
})
const options = {
method: 'POST',
// headers: { 'content-type': 'application/x-www-form-urlencoded' },
// headers: { 'content-type': 'multipart/form-data' },
data: forms,
url,
};
axios(options);
Comments | NOTHING