Created
November 7, 2012 19:06
-
-
Save tarqd/4033671 to your computer and use it in GitHub Desktop.
This file contains 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
function sendBlob(blob) { | |
var xhr = new XMLHttpRequest(); | |
var fd = new FormData(); | |
fd.append('post-data', 'goeshere'); | |
fd.append('foo', 'bar'); | |
// use the right name for the file (the name element of the form ussually) | |
fd.append('file', blob); | |
xhr.open('POST', 'http://YOUR.DOMAIN.HERE/posturl.php', true); | |
xhr.send(fd); | |
} | |
var canvas = document.createElement('canvas'); | |
document.body.appendChild(canvas); | |
var context = canvas.getContext(); | |
var imageObj = new Image(); | |
imageObj.onload = function () { | |
context.drawImage(this, 0, 0); | |
context.toBlob(sendBlob); | |
}; | |
imageObj.src = "http://theimage.com/bla.jpg"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment