-1

I need to pass an image file that I have taken from the camera, directly as param with a POST method in Flutter.

Malisha De Silva
  • 393
  • 2
  • 10

1 Answers1

1

You can use MultipartFile from the http library

var request = http.MultipartRequest('POST', Uri.parse('YourUrl'));
  request.files.add(
    http.MultipartFile.fromBytes(
      'YourField',
      File('YourFilename').readAsBytesSync(),
      filename: 'YourFilename'
    )
  );
  var res = await request.send();
HBS
  • 580
  • 3
  • 6