I\'m looking to stream the image data from a canvas tag to a node.js server. I can handle the server-side code myself, but how can I submit the data from a canvas? I\'m hopi
You can use FormData to emulate a normal "multipart/form-data"
file submit:
canvas.toBlob( function(blob) {
var formData = new FormData();
formData.append("image_file", blob );
var xhr = new XMLHttpRequest;
xhr.open( "POST", "abc.php" );
xhr.send(formData);
}, "image/png");
The canvas method .toBlob
is specified but not implemented, you can use a polyfill
such as canvas-to-blob.js