Skip to content

Instantly share code, notes, and snippets.

@hayes
Created July 25, 2014 23:09
Show Gist options
  • Save hayes/73149125049b18a44b09 to your computer and use it in GitHub Desktop.
Save hayes/73149125049b18a44b09 to your computer and use it in GitHub Desktop.
function upload_file(file) {
var fd = new FormData
, self = this
fd.append('file', file)
var xhr = request.post(url, {}, fd, function(err, response, headers) {
if(err) {
// non 200 resonse will be an error
// handle error
}
//response should be an object constructed from a json response
//headers will be response headers
})
//remove timeout
xhr.timeout = 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment