Created
July 19, 2013 18:44
-
-
Save ajlai/6041417 to your computer and use it in GitHub Desktop.
Async File Uploading in Dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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