高拍仪器的运用体式格局

高拍仪事情道理是:先将图片保留在当地某个文件夹中,然后经由过程上传要领上传到服务器,末了删掉在当地保留的图片.

高拍摄仪切入代码
<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()"> <input
            type="button" value="JPG" onclick="JPG()"> <input
            type="button" value="拍摄彩页PDF" onclick="add_ColorPDF()"> <input
            type="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>
    原文作者:hebeibei
    原文地址: https://segmentfault.com/a/1190000004021094
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞