我想用flutter将图像上传到服务器,在js中,将表单数据与输入文件一起使用,但是随着flutter我不知道该怎么办。
在js中:
formData.append("file", e.clipboardData.files[0]);
formData.append("session", sessionid);
formData.append("fileindex", fileListIndex);
var hostname = window.location.hostname;
var protocol = window.location.protocol;
if (hostname === "localhost") {
xhr.open("POST", "http://localhost:9999/" + uploadpoint, true);
} else if (hostname === "www.aladin.finance") {
xhr.open("POST", protocol + "//uploadfile.aladin.finance" + "/"
+ uploadpoint, true);
} else {
xhr.open("POST", protocol + "//uploadfile." + hostname + "/"
+ uploadpoint, true);
}
xhr.withCredentials = true;
xhr.send(formData);
答案 0 :(得分:0)
Flutter拥有一个称为Dio的出色软件包,用于处理各种http请求。用它做您想要的事非常容易。检查以下内容:https://pub.dev/packages/dio#sending-formdata