Store Image into internal Storage in Ionic?

萝らか妹 提交于 2019-12-25 00:27:18

问题


i am new in Ionic, i am trying to get picture and want to store copy or store image into internal storage so i can get back captured image on any view. I don't know how to store images in internal Storage. I have read this.

this is Helpful but not solving my issue. My Controller is here. Help me in this.

Controller

/**** tab  Camera Controller ***/
.controller('tabCameraCtrl', function($scope, $state, $cordovaCamera) {

    /**********function to Open Camera *********/
     $scope.openCamera = function() {
        document.addEventListener("deviceready", function() {
            var options = {
                quality: 50,
                destinationType: Camera.DestinationType.FILE_URI,
                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(imageURI) {
                var image = document.getElementById('myImage');
                image.src = imageURI;
                $scope.lastPhoto = imageURI;
                window.localStorage.setItem('image',JSON.stringify(imageURI));
                console.log('success')
                console.log('Image Address');
                console.log(imageURI);

            }, function(err) {
                // error
                console.log(err)
            });
        }, false);
    }

Help me to solve this problem.

来源:https://stackoverflow.com/questions/33168688/store-image-into-internal-storage-in-ionic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!