title: How to store a captured image into MySQL database using JavaScript and Node.js
body: <p>I am capturing image using canvas and i want to store a captured image in MySQL Database using Javascript.</p>
  
  <p>This is my code:</p>
  
  <pre><code>&lt;html&gt;  
        &lt;head&gt;
              &lt;meta charset="utf-8"&gt;
              &lt;meta name="viewport" content="width=device-width, maximum-scale=1.0"&gt;
              &lt;style&gt;
                  body {width: 100%;}
                  canvas {display: none;}
              &lt;/style&gt;
              &lt;title&gt;Instant Camera - Remote&lt;/title&gt;
              &lt;script&gt;
  
                  var video, canvas, msg;
                  var load = function () {
                      video  = document.getElementById('video');
                      canvas = document.getElementById('canvas');
                      msg    = document.getElementById('error');
                      if( navigator.getUserMedia ) {
                          video.onclick = function () {
                              var context = canvas.getContext("2d");
                              context.drawImage(video, 0, 0, 240, 320);
                              var image1 = canvas.toDataURL("image/png");
                      document.write('&lt;img src="' + image1 + '" /&gt;');         
                          };
  
                      } else {
                          msg.innerHTML = "Native web camera not supported :(";
                      }
                  };
  
                  window.addEventListener('DOMContentLoaded', load, false);
              &lt;/script&gt;
          &lt;/head&gt;
          &lt;body&gt;
              &lt;video  id="video" width="240" height="320" autoplay&gt; &lt;/video&gt;
              &lt;p      id="error"&gt;Click on the video to send a snapshot to the receiving screen&lt;/p&gt;
              &lt;canvas id="canvas" width="240" height="320"&gt; &lt;/canvas&gt;
          &lt;/body&gt;
          &lt;/html&gt;
  </code></pre>