Skip to content

Instantly share code, notes, and snippets.

@medikoo
Created November 15, 2011 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save medikoo/1367546 to your computer and use it in GitHub Desktop.
Save medikoo/1367546 to your computer and use it in GitHub Desktop.
File upload with xmlHttpRequest and FormData
var files = input.files;
var fd = new FormData();
var xhr = new XMLHttpRequest();
fd.append('file[0]', file[0]);
fd.append('file[1]', file[1]);
xhr.open('POST', '/upload', true);
xhr.send(fd);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment