高拍仪工作原理是:先将图片保存在本地某个文件夹中,然后通过上传方法上传到服务器,最后删掉在本地保存的图片.
高拍摄仪切入代码
<div style="text-align: center;height:300px;"><object classid="clsid:454C18E2-8B7D-43C6-8C17-B1825B49D7DE"id="captrue" width="400" height="300"> </object>
</div>
<div id="fileTr"><div style="text-align: center"><font color="red"></font>选择文件:</div><div><input type="text" id="textfield" style="width: 80%; margin: auto"readonly name="textfield" class="form-control" placeholder="请选择文件"></div><div><input type="button" value="启动主" onclick="startCamera()"> <inputtype="button" value="JPG" onclick="JPG()"> <inputtype="button" value="拍摄彩页PDF" onclick="add_ColorPDF()"> <inputtype="button" value="拍摄黑白PDF" onclick="add_BWPDF()"></div>
</div><script type="text/javascript">var captrue=document.getElementById("captrue");//存放文件名称及其后缀var filenameArray=[];var suffix =[];//创建本地目录以存放图片var path="D:\\";//设置服务器地址IP及端口var hostport=document.location.host;hostport=hostport.split(":");var serverIP = hostport[0];var serverPort = +hostport[1];$(function(){//延迟开启摄像头setTimeout("startCamera()",1000);})function startCamera(){captrue.bStopPlay(); captrue.bStartPlay();}function JPG() {filename = getFileName();var str = captrue.bSaveJPG(path, filename);if (str = true) {alert("拍照成功!");suffix.push(".jpg");filenameArray.push(filename);uploadChange(filename+".jpg");}else {alert("拍照失败!");}}function start_PDF() { filename = getFileName();var str = captrue.bSavePDFStart(path, filename);if (str = true) {suffix.push(".pdf");filenameArray.push(filename);uploadChange(filename+".pdf");}else {alert("拍照失败!");}}function add_ColorPDF(){start_PDF();var str = captrue.bSavePDFColorPage();end_PDF();}function add_BWPDF(){start_PDF();var str = captrue.bSavePDFBWPage();end_PDF();}function end_PDF(){var str = captrue.bSavePDFEnd();if (str = true) {alert("pdf拍摄成功!");}}function uploadPic(){var url= "${root!}/approval/file/uploadDocumentCamera?bsnum=" + bsnum+ "&type=1&document_id=" + document_id + "&document_name="+Power.form.encodeURIParam(document_name,2);var temp=[];for(var i=0;i<filenameArray.length;i++){temp.push(path+filenameArray[i]+suffix[i]);}var filenameString=temp.join("|");var str = captrue.bUpLoadImage(filenameString,serverIP,serverPort, url);}function delPic(fileNameArray){for(var i=0;i<fileNameArray.length;i++){captrue.bDeleteFile(path+fileNameArray[i]+suffix[i]);}}function getFileName() {var date = new Date();var fileName = "高拍仪拍摄";var month = date.getMonth() + 1;if (month < 10) {month = "0" + month;}fileName += month;var day = date.getDate();if (day < 10) {day = "0" + day;}fileName += day;var hour = date.getHours();if (hour < 10) {hour = "0" + hour;}fileName += hour;var minute = date.getMinutes();if (minute < 10) {minute = "0" + minute;}fileName += minute;var second = date.getSeconds();if (second < 10) {second = "0" + second;}fileName += second;var randomNum = Math.floor(Math.random()*1000);if(randomNum<100){if(randomNum<10){randomNum="0"+randomNum;}randomNum="0"+randomNum;}fileName +=randomNum;return fileName;}function uploadChange(filename){document.getElementById('textfield').value =document.getElementById('textfield').value+filename+";";}</script>