I'm trying to create an image upload interface, but to do the resizing on the client side so as to not tax my server (original files are generally 4Mb each, and I need files that are ~300kb)
I have my <input type="file" name="image0" />
, and select my file ("cat.gif").
I then resize it, following the recipe at Mozilla Hacks. I'm left with a blob which I try to put back into my form:
//should I be trying to set the FormData in the presently-blank callback function?
var blob = canvas.toBlob(function(){}, "image/png", 0.95);
var form = document.querySelector("form");
var fd = new FormData(form);
fd.set("image0", blob);
When I submit the form, it sends the original image file ("cat.gif") I inputed, not the modified one I made as a blob. Here's part of the POST payload:
Content-Disposition: form-data; name="image0"; filename="cat.gif"
How do I bind the blob to the form input?