3

I've used this code to use my phone's photo library

// event listener for camera
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
        pictureSource=navigator.camera.PictureSourceType;
        destinationType=navigator.camera.DestinationType;
}  

and that works OK.

I invoke the photo library using:

    navigator.camera.getPicture(onGetPicSuccess, onGetPicFail, { 
        quality: 50,
        destinationType: destinationType.FILE_URI,
        sourceType: pictureSource.PHOTOLIBRARY 
    });

then the function called after successful picture "get"

function onGetPicSuccess(imageData){    

The variable "imageData" looks like this:

blob:http%3A//localhost%3A57492/ac65226c-5698-4345-b301-81205b1403fa    

Now, my question. I'm assuming that is not the actual image data. It's a URL that points to the image on the camera.

Is that correct?

If so, how do I get the actual image data? My end goal is to format the data into the same as what would be used in a HTML file upload form.

Shawn
  • 3,031
  • 4
  • 26
  • 53

1 Answers1

0

Yes, the variable "imageData" does contain an URI to the picture on the camera. I needed to create a FileTransfer() object and give it the URI and it takes care of sending the raw image data.

     var ft = new FileTransfer();
     ft.upload(imageData, "https://somewhere.com/cgi/mPictureUpload.exe", function(result){
         // success
     }, function(error){
         // fail
     }, options);
Shawn
  • 3,031
  • 4
  • 26
  • 53