美文网首页Flutter学习
flutter多图片上传

flutter多图片上传

作者: 男人宫 | 来源:发表于2021-04-20 10:49 被阅读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);
       });
      }
    }
    

    相关文章

      网友评论

        本文标题:flutter多图片上传

        本文链接:https://www.haomeiwen.com/subject/rhoglltx.html