This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
Section: http://www.whatwg.org/specs/web-apps/current-work/#security-with-canvas-elements Comment: I don't see a way to save the canvas data as a BMP or JPEG or anything else that can then be uploaded via a FORM to a web server. This is a requirement, I woudl think. Posted from: 173.9.238.194
Check out the toDataURL() function. It saves the canvas data as a PNG by default, though implementations may offer the ability to save it in other formats such as JPEG or BMP. You can stuff this data in a form the obvious way, and decode it into an actual image file on the server easily.
For what it's worth, firefox 4 recently added support for canvas.getAsFile() (though we added a vendor prefix so it's canvas.mozGetAsFile()) which has a similar syntax as canvas.toDataURL() but also takes an optional name. Arguably canvas.getAsBlob() or canvas.toBlob() would be better since no name is needed. Once a file/blob is retrieved it can be uploaded using XMLHttpRequest and optionally FormData.
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document: http://dev.w3.org/html5/decision-policy/decision-policy.html Status: Partially Accepted Change Description: none yet Rationale: Adding a way to get a File or Blob from a <canvas> makes sense, but I'd like to wait until the File API is a lot more stable and we have more experience with it before putting it in the spec. Marking this LATER for now, but I'll revisit it occasionally.
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document: http://dev.w3.org/html5/decision-policy/decision-policy.html Status: Accepted Change Description: canvas.toBlob() Rationale: Concurred with reporter's comments.