I am working on a SpringMVC application. This application is a form, the user takes their picture with the Jquery WebCam Plufin. I have the webcam working and i am able to take the picture, however i now need to write the image to the database or upload it to the server.
I would like to insert into the database.I am wondering do i upload to the server first before i insert into the database? I am unsure how to approach this. Can someone guide me on this and the best approach to be taken
Code:
$(document).ready(function(){
document.createElement("canvas");
$("#canvas").hide();
$("#camera").webcam({
width: 320,
height: 240,
useMicrophone: false,
mode: "callback",
swffile: "resources/swf/jscam_canvas_only.swf",
quality:85,
onSave: saveCB,
onCapture: function () {
$("#camera").hide();
webcam.save();
$("#canvas").show();
},
debug: function (type, string) {
$("#status").html(type + ": " + string);
}
});
$('#upload').click(function () {
webcam.capture();
return false;
});
$('#retake').click(function () {
$("#canvas").hide();
$("#camera").show();
return false;
});
window.addEventListener("load", function() {
var canvas = document.getElementById("canvas");
if (canvas.getContext) {
ctx = document.getElementById("canvas").getContext("2d");
ctx.clearRect(0, 0, 320, 240);
image = ctx.getImageData(0, 0, 320, 240);
}
}, false);
});
<div id="tab1" class="divGroup">
<form:form id="citizenRegistration" name ="citizenRegistration" method="POST" commandName="citizens" action="citizen_registration.htm">
<div id="divRight" class="mainDiv">
<div class="divGroup" id="divCharInfo">
<label id="status"></label>
<div id="camera"></div>
<div><p><canvas id="canvas" name="photo" height="240" width="320"></canvas></p><form:errors path="photo" class="errors"/></div>
<input id="upload" type="button" value="Take Photo">
<input id="retake" type="button" value="Re-Take Photo">
not sure if you still need an answer on this one. By the way, you are using jscam_canvas_only.swf, that does not support the “save” mode. Try again after moving to jscam.swf…