title: Sending base64 image to server
body: <p>In my application, I need to send base64 format image to server. Currently what I am doing is, I am just sending the base64 image string to the server and and when I retrieve that string back from server, I am not able to display the image, I am getting the error: Image corrupted. What is the exact way to send and fetch the base64 format image? Code I am using is as follows:JS for sending base64 image source:</p>
  
  <pre><code>var imageObj = $("#target")[0];
  var canvas = $("#preview")[0];
  var context = canvas.getContext("2d");
  context.drawImage(imageObj, c.x, c.y, c.w, c.h, 0, 0, canvas.width, canvas.height);
  vData = canvas.toDataURL();
  $('#crop_result').attr('src', vData);
  
  function saveCroppedImage()
  {
     var params='image_name='+vData;
      $.post('localhost/PHP/addImage.php',params,
      function(details){
     }, "json")
    .error(function(jqXHR, textStatus, errorThrown) {
      alert('err');
    });   
  }
  </code></pre>
  
  <p>PHP source code:</p>
  
  <pre><code> &lt;?php
  
  include("config.php");
  
  $clip_Name = $_REQUEST['image_name'];
  $artist_Name ="ash";
  
  $sql = "INSERT INTO tblImageSave (fldImageSource)
         VALUES('$base64Img')";
  
  $retval = mysql_query( $sql, $conn );
  if(! $retval )
  {
    die('Could not enter data: ' . mysql_error());
  }
  
  ?&gt;
  </code></pre>