Skip to content

Instantly share code, notes, and snippets.

@ajlai
Created July 19, 2013 18:44
Show Gist options
  • Save ajlai/6041417 to your computer and use it in GitHub Desktop.
Save ajlai/6041417 to your computer and use it in GitHub Desktop.
Async File Uploading in Dart
void handleUpload() {
var elem = query("#upload") as FileUploadInputElement;
var file = elem.files.first;
FormData fd = new FormData(null);
fd.append("username", "ajlai");
fd.appendBlob("Filename", file);
var req = new HttpRequest();
req.open("POST", "/foo");
req.onReadyStateChange.listen((_) {
if (req.readyState == 4 && req.status == 200) {
// callback here
}
});
req.send(fd);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment