有没有办法使用flutter web将图像上传到服务器/文件夹?

时间:2021-05-10 16:16:21

标签: php dart flutter-web

有没有办法使用 flutter web.js 将图像上传到文件夹。我看到的所有示例都使用 flutter 应用程序或移动设备。我收到各种错误 错误:不支持的操作:_Namespace。 到: 错误:NoSuchMethodError:'readAsBytesSync' 找不到方法 接收方:“blob:http://localhost:56058/83544616-abe2-4f5c-ac7b-a15a52e4d2e1” 参数:[]

我一直在使用这个带有图像选择器和 php 后端的 flutter 函数。

 Future _uploadimages() async {
     var apiUrl = Uri.parse("http://www.redhowler.com/web/db/upload.php");
     String bytes = base64Encode(_image.readAsBytesSync());
     

    Map mappedData = {
      'name': fileName,
      'image': bytes
    };
     
    http.Response response = await http.post(apiUrl, body: mappedData);
    var data = jsonDecode(response.body);
    print(data);
  }

0 个答案:

没有答案
相关问题