`
阅读更多
项目目录:
|-cabs\Package.cab->摄像头控制控件
|-js\*.js jquery文件
|-test1.html->前台网页
|-test1.js->js文件
|-test.php->接收摄像头采集照片结果的php文件




前台网页代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>video cap control demo</title>
<script type="text/javascript" src="./js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="test1.js"></script>
</head>
<body>

<form action="test.php" id="cap_form" method="post">
<input type="hidden"  id="picData" name="picData">
<object classid="clsid:34681DB3-58E6-4512-86F2-9477F1A9F3D8"
id="WebVideoCap1" codebase="./cabs/Package.cab#version=1,0,0,50" width="636" height="238">
<param name="Visible" value="0">
<param name="AutoScroll" value="0">
<param name="AutoSize" value="0">
<param name="AxBorderStyle" value="1">
<param name="Caption" value="WebVideoCap">
<param name="Color" value="4278190095">
<param name="Font" value="宋体">
<param name="KeyPreview" value="0">
<param name="PixelsPerInch" value="96">
<param name="PrintScale" value="1">
<param name="Scaled" value="-1">
<param name="DropTarget" value="0">
<param name="HelpFile" value>
<param name="PopupMode" value="0">
<param name="ScreenSnap" value="0">
<param name="SnapBuffer" value="10">
<param name="DockSite" value="0">
<param name="DoubleBuffered" value="0">
<param name="ParentDoubleBuffered" value="0">
<param name="UseDockManager" value="0">
<param name="Enabled" value="-1">
<param name="AlignWithMargins" value="0">
<param name="ParentCustomHint" value="-1">
</object>
<hr/>

<input type="hidden" name="pic_data" id="pic_data"/>
照片描述:<input type="text" name="desc" id="desc"/>

<input type="button" value="照相" id="btn_cap"/>

<input type="button" value="提交" id="btn_submit"/>

</form>
</body>
</html>


------------------------------------------------------------
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文件

<?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 "<img src='test.jpg'/>"

?>

分享到:
评论
2 楼 peihexian 2010-09-23  
ie8可以通过的,没有问题。
1 楼 tidelgl 2010-09-23  
IE才能用的操作,而且没有权限,IE8都不通过这个控件

相关推荐

Global site tag (gtag.js) - Google Analytics