[whatwg] canvas, img, file api and blobs

Stef Epardaud stef at epardaud.fr
Tue Feb 16 04:01:12 PST 2010

On Tue, Feb 16, 2010 at 03:48:04AM -0800, Jonas Sicking wrote:
> If you have the FormData object [1], then why is it simpler to use
> <form> submission?
> [1] http://dev.w3.org/2006/webapi/XMLHttpRequest-2/Overview.html#the-formdata-interface

Unless I'm missing the point, I find it simpler to use a regular <form>
submission, which would use the processed files as well as other <input>
elements rather than build the XMLHttpRequest, build the FormData (via
the constructor, unless we can obtain it from the filled-in <form> but I
didn't see any mention of FormData in the HTML5 spec), then send the
request and deal with the answer.

If I can turn the contents of a <canvas> into a File (possibly via Blob
and/or Storage), then replace the <input type=file>'s list of files,
then all the submitting is done by the browser.

I think it is simpler than doing it AJAX, which is not to say that the
more complex AJAX way isn't better, I think both should be possible.
Also it would be consistent with the fact that every other <input> type
can be set/filtered by JS after user input, and still rely on regular
<form> submission.
Stéphane Epardaud

More information about the whatwg mailing list