Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Data returning a .bin file #30

Closed
tyokobo opened this issue Oct 24, 2015 · 0 comments
Closed

Data returning a .bin file #30

tyokobo opened this issue Oct 24, 2015 · 0 comments

Comments

@tyokobo
Copy link

tyokobo commented Oct 24, 2015

Hi Leemachin, first thanks a lot, I loved it.

Second, when I record... the data in the DB is coming as a .bin file... Any thoughts on that?
I'm using it on a codeigniter system.

Here is my View

<title>WebCam</title>
    <style type="text/css">

        #content{
            margin: 0 auto;
            width: 1000px;
            position: relative;

        }

        .fotografia{
            width: 320px;
            height: 240px;
            border: 20px solid #333;
            background: #eee;
            -webkit-border-radius: 20px;
            -moz-border-radius: 20px;
            border-radius: 20px;
            position: relative;
            margin-top: 50px;
            margin-bottom: 50px;

        }

        .marca {
            z-index: 2;
            position: absolute;
            color: #eee;
            font-size: 10px;
            bottom: -16px;
            left: 152px;

        }

        #obturador,#guardarFoto{
            padding: 10px;
            border: 1px solid;
            background-color: #444;
            color: #fff;
            cursor: pointer;
            margin-left: 50px;

        }


    </style>
</head>

<body>
    <div id="content">
        <div style="float:left;width:50%">
            <div id="webcam" class="fotografia">
                <span class="marca">tutoriales.com</span>
            </div>
        </div>
        <div style="float:left;width:50%">
            <div id="say-cheese-snapshots" class="fotografia">
                <span class="marca">Snapshots</span>

            </div>
        </div>
        <div style="clear:both"></div>

        <div style="float:left;width:50%">
            <span id="obturador">Tomar foto</span>
        </div>

        <div style="float:left;width:50%">
            <span id="guardarFoto">Guardar Foto</span>
        </div>

        <div class="fotografia">
            <img id="fotoGuardada" src="" style="display:none" />
            <span class="marca">Foto Armazenada</span>

        </div>

    </div>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
    <script src="<?php echo base_url() ?>assets/js/say-cheese.js"></script>
    <script type="text/javascript">
       var img=null;
       var sayCheese = new SayCheese('#webcam',{snapshots: true});

       sayCheese.start();

       $('#obturador').bind('click', function(e){
           sayCheese.takeSnapshot(320,240);
           return false;
       });

       sayCheese.on('snapshot', function(snapshot){
           img = document.createElement('img');

           $(img).on('load', function(){
               $('#say-cheese-snapshots').html(img);
           });
           img.src = snapshot.toDataURL('image/png');
       });

        $('#guardarFoto').on('click', function(canvas){
         var src = img.src;
         alert("#guardarFoto clicked!");
         data = {
             src: src
         };
         $.ajax({
             url: '<?php echo base_url() ?>webcam/ajax',
             data: data,
             type: 'post',
             sucess: function(respuesta) {
                 $('#fotoGuardada').attr('src', respuesta).show(500);
             }
         });
        });


    </script>
</body>

Here is my controller

load->model(array('Fotos_model')); } public function index() { $this->load->view('webcam/index_view'); } public function ajax () { $src = $this->input->post('src'); $this->Fotos_model->gravarFoto($src); $foto = $this->Fotos_model->getLastFoto(); $this->output->set_output ($foto); } } ``` And my Model db->insert('fotos',array('foto'=>$foto)); } public function getLastFoto() { return $this->db->order_by('id','desc')->get('fotos')->row()->foto; } ``` }
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants