php控制摄像头抓拍照片

项目目录:
|-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'/>"

?>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

peihexian

你的鼓励是我创作的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值