Skip to content

Instantly share code, notes, and snippets.

@f0t0n
Created September 24, 2012 19:32
Show Gist options
  • Save f0t0n/3777826 to your computer and use it in GitHub Desktop.
Save f0t0n/3777826 to your computer and use it in GitHub Desktop.
for (var i = 0, l = e.dataTransfer.files.length; i < l; i++) {
var file = e.dataTransfer.files[i],
xhr = new XMLHttpRequest;
xhr.open('post', 'upload.php', true);
xhr.onreadystatechange = function () {
if (this.readyState != 4) {
return;
}
// ...
}
xhr.setRequestHeader('Content-Type', 'multipart/form-data');
xhr.setRequestHeader('X-File-Name', file.fileName);
xhr.setRequestHeader('X-File-Size', file.fileSize);
xhr.send(file);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment