Image data not sending properly - Ajax, Cordova <p>The following code is to take picture and send to server using ajax, but the image data not properly send.</p> <pre><code> &lt;script&gt; var pictureSource; // picture source var destinationType; // sets the format of returned value var image = ""; document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { function alertDismissed() { }; pictureSource = navigator.camera.PictureSourceType; destinationType = navigator.camera.DestinationType; } function capturePhoto() { navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50, destinationType: destinationType.DATA_URL }); } function onPhotoDataSuccess(imageData) { var smallImage = document.getElementById('smallImage'); smallImage.style.display = 'block'; smallImage.src = "data:image/jpeg;base64," + imageData; image = "data:image/jpeg;base64," + imageData; alert("Image = "+image); } function onFail(message) { alert('Failed because: ' + message); } function submitFunction() { function alertDismissed() { }; var dataString = 'image='+image; $.ajax({ type: "POST", url: "url.php", data: dataString, cache: false, success: function(result){ } }); } &lt;/script&gt; &lt;input type="button" id="camera" class="btn btn-primary btn-large btn-block" value="Take Photo" onclick="capturePhoto();"/&gt; &lt;input type="submit" class="btn btn-primary btn-large btn-block" value="Next" onclick="submitFunction();" /&gt; &lt;img style="display:none;width:60px;height:60px;" id="smallImage" src="" /&gt; </code></pre> <p>The image is displaying properly, and alert shows "Image = data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDABALDA4M......o7cUAPFJR9KWmgP/9k=".</p> <p>But, in the following php, the $_POST['image'] is not receiving the proper data, it missing somecharacters like '+' and also replacing it with space or new line. So, when I returning back from db in other page, image not displayed properly.</p> <p>url.php</p> <pre><code>$con=mysql_connect('server','user','password') or die("Failed to connect to MySQL: " . mysql_error()); $db=mysql_select_db('db',$con) or die("Failed to connect to MySQL: " . mysql_error()); $retval = mysql_query( "UPDATE tablename SET photo='".$_POST['image']."' WHERE ID='".$_POST['id']."'", $con ); echo $_POST['image']; </code></pre>