Javascript 在Codeigniter网络摄像头中使用文件夹和数据库中的上载图像

Javascript 在Codeigniter网络摄像头中使用文件夹和数据库中的上载图像,javascript,jquery,css,html,codeigniter,Javascript,Jquery,Css,Html,Codeigniter,查看代码 <button type="button" class="btn btn-info" onClick="take_snapshot()"><i class="fa fa-camera fa-fw"></i>Capture</button> <div class="col-md-3 col-md-offset-1 imager" id="results" name="results"> <input

查看代码

<button type="button" class="btn btn-info" onClick="take_snapshot()"><i class="fa fa-camera fa-fw"></i>Capture</button>
<div class="col-md-3 col-md-offset-1 imager" id="results" name="results">       
    <input id="results" type="" name="results" value=""/>
    <div class="clearfix" id="my_camera"></div>
    <input type="file" name="webcam">

    function take_snapshot() {                
        Webcam.snap(function (data_uri) {
            document.getElementById('results').innerHTML ='<img src="' + data_uri + '"/>';
        });
        Webcam.upload(data_uri, '"<?php echo base_url(); ?>Enquiry_Management/Demosave"', function(code, text) {
            if (code === '200') {
                alert ('ok');
            } else {
                alert('error');
            }
        });
    }

    Webcam.set({
        width: 320,
        height: 240,
        image_format: 'jpeg',
        upload_name: 'webcam',
        jpeg_quality: 90
    });

    Webcam.attach('#my_camera')
$filename = date('YmdHis').".jpg";
$filepath = FCPATH.'uploads/'.$filename;
$result = move_uploaded_file($_FILES['webcam']['tmp_name'],$filepath);
说明

我想通过网络摄像头点击图像,并使用Codeigniter MVC框架保存到文件夹和数据库中。这是我的视图和控制器代码。请帮助我在控制器中保存和打印图像文件名。

查看以下内容:

您可以使用此功能将图像上载到服务器

例如:

 $config['upload_path']          = './uploads/';//your path to saving it
            $config['allowed_types']        = 'gif|jpg|png';
            $config['max_size']             = 100;
            $config['max_width']            = 1024;
            $config['max_height']           = 768;

            $this->load->library('upload', $config);

            if ( ! $this->upload->do_upload('userfile'))//the name of the input. In your case 'webcam' instead of 'userfile'
            {
                    $error = array('error' => $this->upload->display_errors());

                    $this->load->view('upload_form', $error);
            }
希望这有帮助