1

Actually my question is same with this question: How to upload images and file to a server in Flutter?, I have tried the solution there but I when I try to check the backend, the file is still null Here is the part of the code

var url = Uri.parse("$loginUrl/saving");
      var request = new http.MultipartRequest("POST", url);
      request.headers.addAll(headers);
      request.fields['start_date'] =
          "2021-10-10 14:42:09.369599"; //"$startDate";
      request.fields['end_date'] = "2021-10-10 14:41:09.369599"; // "$endDate";
      request.fields['id_download'] = "0";
File file = File(
          "/data/user/0/com.example.project/cache/file_picker/ic_launcher.png");
      Uint8List bytes = file.readAsBytesSync();
      List<int> sending = bytes;

      request.files.add(await http.MultipartFile.fromBytes(
          'file_upload', file.readAsBytesSync(),
          // contentType: new MediaType('application', 'octet-stream'),
          filename: "ic_launcher.png"));
      print(request);
      print("kkkk");
      var res = await request.send().timeout(Duration(seconds: 5));
      final respStr = await res.stream.bytesToString();

is there something that I should add more?

wahyu
  • 1,679
  • 5
  • 35
  • 73

0 Answers0