I am developing a phonegap application and using the navigator.getPicture method to get the images.
The way I am getting the picture is:
navigator.camera.getPicture(onSuccess, onFail, { quality: 50, 
destinationType: Camera.DestinationType.FILE_URI });
function onSuccess(imageURI) {
    var image = document.getElementById('myImage');
    image.src = imageURI;
}
Just like the example in phonegap doc's.
I want to be able to use the imageURI and then convert it to image data in order to upload it later. (I don't want to use phonegap's FileTransfer)
So far I have tried both Get image data in JavaScript? and How can you encode a string to Base64 in JavaScript?
When I try the following,
function onSuccess(imageURI) {
    getBase64Image(imageURI);
}
function getBase64Image(img) {
    // Create an empty canvas element
    var canvas = document.createElement("canvas");
    canvas.width = img.width;
    canvas.height = img.height;
    // Copy the image contents to the canvas
    var ctx = canvas.getContext("2d");
   ctx.drawImage(img, 0, 0);
   // Get the data-URL formatted image
   // Firefox supports PNG and JPEG. You could check img.src to
   // guess the original format, but be aware the using "image/jpg"
   // will re-encode the image.
   var dataURL = canvas.toDataURL("image/png");
   console.log(dataURL); //here is where I get 'data:,'       
   return dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
}
And print dataURL before returning. I just get data:, as the content. 
Any ideas on what I'm doing wrong?
 
     
    