Skip to content

Instantly share code, notes, and snippets.

@adis-io
Created November 21, 2011 16:55
Show Gist options
  • Save adis-io/1383211 to your computer and use it in GitHub Desktop.
Save adis-io/1383211 to your computer and use it in GitHub Desktop.
var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://image.torrent.kg/images/U8x5261.png', false);
xhr.responseType = 'arraybuffer';
xhr.send();
var blob = new WebKitBlobBuilder();
blob.append(xhr.response);
var file = blob.getBlob('image/png');
console.log(file)
var fd = new FormData();
fd.append("image[0]", file);
var xhr2 = new XMLHttpRequest();
xhr2.open('POST', 'http://image.torrent.kg/api/upload', false);
xhr2.send(fd);
console.log(xhr2.responseText);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment