function upDataList(url){
var f = document.getElementById('picFile');
var formData = new FormData();
formData.append('file', f.files[fileLength]);
fetch(url, {
method: 'post',
body: formData,
credentials: "include",
})
.then(response => response.json())
.catch(error => console.error('Error:', error))
.then(data => {
console.log(data)
fileLength++;
if (data.code == 200) {
if(fileLength === f.files.length){
P.$.dialog.success("success.");
sub_win.data['reload'] = true;
sub_win.close();
fileLength = 0;
} else {
upDataList(url);
}
} else {
P.$.dialog.success("上传附件失败!" + data.msg);
sub_win.close();
}
});
}
fetch 循环 多文件上传
最新推荐文章于 2024-05-29 10:57:47 发布