I'm saving pictures in my application using the camera feature of Phonegap. When I try to get the file through its saved file_URI (that I got from the camera), the image doesn't load.
function toBase64(url) { var canvas = document.createElement("canvas"); var ctx = canvas.getContext('2d'); var img = new Image(); img.src = url; if ( img.height != 0 ) { var height = img.height, width = img.width; canvas.height = height; canvas.width = width; ctx.drawImage(img, 0, 0, width, height); try { var dataURL = canvas.toDataURL("image/jpg"); return dataURL.replace(/^data:image\/(png|jpg);base64,/, ""); } catch (err) { console.log("ERROR " + err);} } else { alert("Wrong path!"); } }
The images are saved in the cache folder of the application (/data/data/my.app/cache)
Any ideas of where the problem could be from ?