flutter多图片上传
2021-04-20 本文已影响0人
男人宫
项目中使用到的多图上传服务器
//提交数据
void _postAllImage() async{
FormData formData = FormData.fromMap({
"newNames":"",
});
for(int i = 0; i < _images.length; i++) {
File imaeFlie = _images[i];
String path = imaeFlie.path;
var imageName = path.substring(path.lastIndexOf("/") + 1, path.length);
var file = await MultipartFile.fromFile(path, filename:imageName);
formData.files.add(MapEntry("file",file));
}
DioUtils.postHttp("file/upload",parameters:formData, onSuccess: (response){
print(response);
},onError: (code, eror){
print(eror);
});
}
}