Reputation: 7180
I am using something like this for my tests:
_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);
}
And yes I know it's only the filename that I am sending, but how can I send the whole file to the server?
Upvotes: 2
Views: 1446
Reputation: 684
They introduced a new function to append files with a given fileName:
FormData.appendBlob(String name, Blob value, [String filename])
Upvotes: 4
Reputation: 76193
You should be able to upload file
with :
formData.append('file', file);
Upvotes: 6