Taking a picture

Hi,

Don’t know if it’s the right category so let me know.

I’m trying to take a photo and after upload on a server. But i’m stuck at the first step.

I’ve this code at the moment:

app.controller('AddPhotoCtrl', function($scope, $rootScope, $http, $state, $cordovaCamera) {
    document.addEventListener("deviceready", function () {

        $scope.takePic = function() {
            var options = {
                quality: 50,
                destinationType: Camera.DestinationType.DATA_URL,
                sourceType: Camera.PictureSourceType.CAMERA,
                allowEdit: true,
                encodingType: Camera.EncodingType.JPEG,
                targetWidth: 100,
                targetHeight: 100,
                popoverOptions: CameraPopoverOptions,
                saveToPhotoAlbum: false,
                correctOrientation:true
            };

            $cordovaCamera.getPicture(options).then(function(imageData) {
                var image = document.getElementById('myImage');
                image.src = "data:image/jpeg;base64," + imageData;
                alert('OK');
                alert(image.src);
            }, function(err) {
                alert('BUG');
            });

        };

    }, false);
});

So I press on my bouton (takePic()), I take the picture and after that I’ve 2 boutons from android Not save or Save. Obviously I press on Save and nothing happen. I don’t have the alert OK or BUG.

What I’m doing wrong ?

Thanks

It’s working :smile:

app.controller('AddPhotoCtrl', function($scope, $rootScope, $http, $state, $cordovaCamera) {
    document.addEventListener("deviceready", function () {
        $scope.takePic = function() {
            var options = {
                quality: 50,
                //destinationType: Camera.DestinationType.DATA_URL,
                destinationType: Camera.DestinationType.FILE_URL,
                sourceType: Camera.PictureSourceType.CAMERA,
                allowEdit: true,
                encodingType: Camera.EncodingType.JPEG,
                targetWidth: 600,
                popoverOptions: CameraPopoverOptions,
                saveToPhotoAlbum: false,
                correctOrientation:true
            };
            $cordovaCamera.getPicture(options).then(
                function(imageData) {
                    $scope.picData = imageData;
                    alert('ok');
                    alert(imageData);
                },
                function(err){
                     alert('wrong');
                }
            );
        };
    }, false);
});

Now I must found How to upload this on my server :weary: