我在测试中使用这样的东西:
_sendFormData(final File file) {
final HttpRequest httprequest = new HttpRequest();
final String filename = file.name;
httprequest.open('POST', "http://localhost:8080/api/file/upload");
httprequest.on.readyStateChange.add((e) {
if (httprequest.readyState == 4 && httprequest.status == 200) {
window.alert("upload complete");
}
});
print("Filename: ${filename}");
final FormData formData = new FormData();
formData.append('file', null, filename);
httprequest.send(formData);
}
是的,我知道这只是我要发送的文件名,但是如何将整个文件发送到服务器?