项目目录:
|-cabs\Package.cab->摄像头控制控件
|-js\*.js jquery文件
|-test1.html->前台网页
|-test1.js->js文件
|-test.php->接收摄像头采集照片结果的php文件
前台网页代码:
video cap control demoid="WebVideoCap1" codebase="./cabs/Package.cab#version=1,0,0,50" width="636" height="238">
照片描述:
------------------------------------------------------------
test1.js文件
String.prototype.replaceAll = function(s1, s2) {
return this.replace(new RegExp(s1, "gm"), s2);
}
$(function() {
document.getElementById('WebVideoCap1').zoomPercent=46;
$('#btn_cap').click(function() {
document.getElementById('WebVideoCap1').cap();
}), $('#btn_submit').click(function() {
if ($('#desc').val().length==0) {
alert('input some text!');
$('#desc').focus();
return false;
}
document.getElementById('pic_data').value=document.getElementById('WebVideoCap1').jpegBase64Data;
document.forms[0].submit();
})
});
------------------------------------------------------------------
test.php文件
$file_name = "test.jpg";
$pic_data=$_POST["pic_data"];
$real_picture_data=base64_decode($pic_data)
$file=fopen($file_name,"w");
fwrite($file,$real_picture_data);
fclose($file);
print "
"
?>