1
votes

I am trying to use the Apache Cordova Camera API for displaying the image retrieved from the camera. I am getting the camera call, and able to click the picture. I am getting the file url as

file:///mnt/.....something.jpg

Now, I am not able to set this image in an existing image tag, using jQuery.

The Code I have used is:

$("#img").attr("src", "data:image/jpeg;base64," + imageData);

where imageData is the return value of the camera success callback.

The Options for Cordova Image function, which I am using

destinationType = 0; sourceType = 1; encodingType = 0;

There is no image which comes up on the tag. What can be the issue here?

1
Could you add your html code to check?Hazem Hagrass

1 Answers

1
votes

This a quick example about how this should work:

function changePhoto(){
        var cameraSuccess = function(imageURI){
            //add dummy param to disable caching
            var random = Math.floor(Math.random()*1000);
            var newImagePath = imageURI + "?dummy=" + random;
            $("#img").attr("src",newImagePath);
        };
        var cameraError = function(msg){
            alert(msg);
        };

        navigator.camera.getPicture( cameraSuccess, cameraError, { 
            quality: 50, 
            destinationType: Camera.DestinationType.FILE_URI,
            sourceType: Camera.PictureSourceType.PHOTOLIBRARY
        });
    },