Q:

How to upload canvas image in server?

I Take a snap by using HTML5 Now i want to upload that image into server(by using spring mvc+Ajax i want to upload that image in google app blob store) Any one Help me
 here My Sample code 
 <video id="video" width="640" height="480" autoplay></video>
 <button id="snap">Snap Photo</button>
<canvas id="canvas" width="640" height="480"></canvas>
<button id="getBase" onclick="getBase()">Get Base64</button>
<textarea id="textArea"></textarea>

 <script>

// Put event listeners into place
window.addEventListener("DOMContentLoaded", function() {
    // Grab elements, create settings, etc.
    var canvas = document.getElementById("canvas"),         
    context = canvas.getContext("2d"),
    video = document.getElementById("video"),
    videoObj = { "video": true },
    errBack = function(error) {
    console.log("Video capture error: ", error.code); 
    };

    // Put video listeners into place
    if(navigator.getUserMedia) { // Standard
        navigator.getUserMedia(videoObj, function(stream) {
            video.src = stream;
            video.play();
        }, errBack);
    } else if(navigator.webkitGetUserMedia) { // WebKit-prefixed
        navigator.webkitGetUserMedia(videoObj, function(stream){
            video.src = window.webkitURL.createObjectURL(stream);
            video.play();
        }, errBack);
    }

    // Trigger photo take
    document.getElementById("snap").addEventListener("click", function() {
        context.drawImage(video, 0, 0, 640, 480);
    });

    document.getElementByID("getBase").addEventListener("click", getBase());

}, false);                  

function getBase(){
    var imgBase = canvas.toDataURL("image/png");
    alert(imgBase);

    document.getElementByID("textArea").value=imgBase;
}

`
Any one help me How can i upload image on server by using ajax

A:

You likely want to use a FormData object. Mozilla has a pretty good guide on how to do that. They even cover sending files specifically. In your case, I'd recommend storing the image data as a blob.

