title: Convert Data URI to File then append to FormData
body: <p>I've been trying to re-implement an HTML5 image uploader like the one <a href="http://hacks.mozilla.org/2011/01/how-to-develop-a-html5-image-uploader/" rel="noreferrer">on the Mozilla Hacks</a> site, but that works with WebKit browsers. Part of the task is to extract an image file from the <code>canvas</code> object and append it to a <a href="http://dev.w3.org/2006/webapi/XMLHttpRequest-2/#the-formdata-interface" rel="noreferrer">FormData</a> object for upload.</p>
  <p>The issue is that while <code>canvas</code> has the <code>toDataURL</code> function to return a representation of the image file, the FormData object only accepts File or Blob objects from the <a href="http://www.w3.org/TR/file-upload/" rel="noreferrer">File API</a>.</p>
  <p>The Mozilla solution used the following Firefox-only function on <code>canvas</code>:</p>
  <pre><code>var file = canvas.mozGetAsFile(&quot;foo.png&quot;);
  </code></pre>
  <p>...which isn't available on WebKit browsers. The best solution I could think of is to find some way to convert a Data URI into a File object, which I thought might be part of the File API, but I can't for the life of me find something to do that.</p>
  <p>Is it possible? If not, any alternatives?</p>