1

There is a web service, where you can send a form, it includes 2 images, this works well with Postman. enter image description here

This code has been used, even with the Dio library, but it is the same error.

String token = '';
Future<String> uploadImage(File file) async {
  String fileName ='HOLA.png';
  Dio dio = new Dio();
   FormData formData = FormData.fromMap({
       'nombre_categoria': 'wendux',
       'estado_categoria': 'activado',
       'tipo_fastask': 'Fastask',
       "img_icono": 
       await   MultipartFile.fromFile(_image.name.toString(), 
        filename: fileName),
        });
        final response = await dio.post(
      "locahost:7700/api/admin/servicios/agregar_categoria",
        data: formData,
        options: Options(headers: <String, String>{
        'Authorization': 'Bearer ' + token,
        }),
        );
        return response.data['id'];
}


Future obtenerimgen() async {
  html.File imageFile =
  await ImagePickerWeb.getImage(outputType:         ImageType.file);
  setState(() {
    if(imageFile != null) {
       print(imageFile.name.toString());
       _image = imageFile;
    } else {
        print('No image selected.');
    }   
  });
}
     

0 Answers0