Is there some offset I should be accounting for when I upload an image in this manner? If i simple send the file, I can write it back out as a valid JPG but if I write the data submitted via readAsBinaryString, the file is approximately 50% larger and corrupt.
Any thoughts?
here's the javascript:
var file = e.dataTransfer.files[0];
var reader = new FileReader();
reader.onloadend = function(event) {
var xhr = new XMLHttpRequest();
xhr.open("POST", "/upload/image/");
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xhr.send(event.target.result);
};
reader.readAsBinaryString(file);
On the server side, I'm using python. If I simply dump the request.raw_post_data I can see the data has been submitted successfully ... problem is that I can't figure out how to write back out to a valid file.
I understand that I'm not handling something appropriately server side, but what?