我正在开发一个SpringMVC应用程序。这个应用程序是一个表单,用户使用Jquery WebCam插件拍摄他们的照片。我有摄像头工作,我可以拍摄这张照片,但我现在需要写的图像到数据库或上传到服务器。
我想插入数据库。我想知道在插入数据库之前是否先上传到服务器?我不知道如何处理这件事。有人能指点我这件事和采取的最佳方法吗?
代码:
$(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">发布于 2013-02-02 23:22:20
不知道你是否还需要这个答案。顺便说一下,您使用的是jscam_canvas_only.swf,它不支持“保存”模式。搬到jscam.swf后再试.
https://stackoverflow.com/questions/14471015
复制相似问题