title: Save Canvas using Codeigniter
body: <p>I created HTML5 Canvas Drawing App using <a href="https://www.youtube.com/watch?v=m4sioSqlXhQ" rel="nofollow">this</a> video tutorial series.Now I want to save it as an image in database using codeigniter.Also I want to allow user to enter name for that image before saving it in database.I'm new to codeigniter.Can anyone help me with this.Here what I have done so far</p>
  
  <p>html code
  .......................</p>
  
  <pre><code>&lt;div class="col-lg-3"&gt;
        &lt;div id="toolbar"&gt;    
            &lt;div id="rad"&gt;
                Radius &lt;span id="radval"&gt;10&lt;/span&gt;
                    &lt;div id="decrad" class="radcontrol"&gt;-&lt;/div&gt;
                    &lt;div id="incrad" class="radcontrol"&gt;+&lt;/div&gt;
                    &lt;div id="colors"&gt;&lt;/div&gt;
                    &lt;div id="save"&gt;Save&lt;/div&gt;
            &lt;/div&gt;
        &lt;/div&gt;
            &lt;canvas id="canvas"&gt;&lt;/canvas&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>javascript code for saving
  ..................................... </p>
  
  <pre><code>var saveButton=document.getElementById('save');
      saveButton.addEventListener('click',saveImage);
      function saveImage(){
          var data=canvas.toDataURL();
          var request=new XMLHttpRequest();
  
          request.onreadystatechange=function(){
              if(request.readyState==4&amp;&amp; request.status==200){
                 var response= request.responseText;
                  console.log(response);
              }
          }
  
          request.open('POST','http://localhost/cafdc/MainController/save',true);
          request.setRequestHeader('Content-type','application/x-www-form-urlencoded');
          request.send('img='+data);
      }
  </code></pre>