I tried to do this work 1. capture a photo
2. Get a picture from a saved location
3. Read the photo as base64
I followed this methodology:
var cameraOptions = {};
function capturePhoto() {
console.log("capture photo");
cameraOptions = { quality: 70, destinationType: Camera.DestinationType.FILE_URI, sourceType: Camera.PictureSourceType.CAMERA, saveToPhotoAlbum: true };
doIt();
}
function doIt() {
navigator.camera.getPicture(onCameraSuccess, onCameraFail, cameraOptions);
}
function onCameraSuccess(imageURI) {
console.log("Camera Success");
$('#MokhalfaPhotoLocation').val(imageURI);
console.log("Image URI: " + imageURI);
window.resolveLocalFileSystemURI(imageURI, onResolveImageSuccess, onFail);
}
function onResolveImageSuccess(fileEntry) {
fileEntry.file(gotFile, onFail);
}
function gotFile(file) {
readDataUrl(file);
}
function readDataUrl(file) {
console.log("read file as dataUrl");
var reader = new FileReader();
reader.onloadend = function (evt) {
console.log("Read as data URL");
window.localStorage.setItem("mokhalfaPhotoURL", evt.target.result);
};
reader.readAsDataURL(file);
}
this chain works fine until CameraSuccess fires on the line
window.resolveLocalFileSystemURI(imageURI, onResolveImageSuccess, onFail);
he introduced the onFail event with error code = 5
btw, this code worked fine on Android, but the problem is here in Windows Phone 7 does anyone know what the problem is?
source
share