Note that there are some explanatory texts on larger screens.

plurals
  1. POData not convert into Base64
    text
    copied!<p>I'm trying to use image captured with webcam and want to show over webpage and want to store that also.Here My code trying to convert captured image into Base64 format but it is failed to convert into Base64.Kindly give me solution how can i convert this into Base64.</p> <p>My code is:</p> <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script src="/static/webcam/New/jquery-1.7.1.min.js" type="text/javascript"&gt; &lt;/script&gt; &lt;script src="/static/webcam/New/webcam.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; function showWebcam(){ $("#camera").webcam({ width: 320, height: 240, mode: "callback", swffile: "/static/webcam/jscam.swf", quality: 100, onCapture: function () { }, onTick: function () {}, onSave: function () {}, onLoad: function () {}, debug: function(type, string) { $('#wcStatus').append(type + ": " + string + '&lt;br /&gt;&lt;br /&gt;'); } }); } function capture_image(){ void(0); var canvas = document.getElementById('canvas'); var context = canvas.getContext("2d"); // var img = canvas.toDataURL("image/png"); var img = canvas.toDataURL(); alert(img); var item_image = img.replace(/^data:image\/(png|jpg);base64,/, "") ; alert(item_image); document.getElementById('myImg').src=item_image; } &lt;/script&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt; &lt;title&gt;JSP Page&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="camera"&gt;&lt;/div&gt; &lt;div id="camList"&gt;&lt;/div&gt; &lt;div id="wcStatus"&gt;&lt;/div&gt; &lt;button onclick="showWebcam();"&gt;Use Webcam Instead&lt;/button&gt; &lt;button onclick="javascript:capture_image();"&gt;Take a picture!&lt;/button&gt; &lt;div id="capture_images"&gt;&lt;input id="capture_image" type="hidden" value="" name="capture[image]"&gt;&lt;/div&gt; &lt;img id="myImg" src="face.png" border=1&gt; &lt;p&gt;&lt;canvas id="canvas" width="320" height="240"&gt; &lt;/canvas&gt; &lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload