0
点赞
收藏
分享

微信扫一扫

flutter多图片上传

快乐小码农 2021-10-04 阅读 44

项目中使用到的多图上传服务器

 //提交数据
  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);
   });
  }
}
举报

相关推荐

0 条评论