Ionic: Cordova GetPicture FileURL contain Number at the place of file name -


i selecting image galary , saving app directory, facing issue when image selected file name in url random number like:

"/media/external/images/media/26183" 

i not getting exact file name, reason when file going copy file not found error throwing code fetching , saving are:

     $scope.changeprofile = function() {       var options = {         quality: 30,         destinationtype: camera.destinationtype.native_uri,         sourcetype: camera.picturesourcetype.photolibrary,          encodingtype: camera.encodingtype.jpeg,          mediatype:camera.mediatype.picture       };        navigator.camera.getpicture( oncamerasuccess, oncameraerror, options);       };  function oncamerasuccess(imageuri) {           console.log(imageuri);            window.resolvelocalfilesystemurl(imageuri,onsucessfilepath, onerrorfilepath);            }           function onerrorfilepath(error){               console.log(error);           }           function onsucessfilepath(fileentry){               console.log(fileentry);               var filepath=fileentry.nativeurl;           var name = filepath.substr(filepath.lastindexof('/') + 1);           var namepath = filepath.substr(0, filepath.lastindexof('/') + 1);             var newname = "profile_pic";           $cordovafile.removefile(cordova.file.datadirectory, newname)           .then(function (success) {               console.log(success);           }, function (error) {               console.log(error);           });           // var newname = makeid() + name;           $cordovafile.copyfile(namepath, name, cordova.file.datadirectory, newname)           .then(function(info) {           console.log(info);             profileimage.image = cordova.file.datadirectory+newname;             $scope.picupload = true;               },             function(err){             console.log(err);             });           }            function oncameraerror(err){             console.log(err);             $ionicloading.show({template: 'error in loading', duration:500});           } 

please tell me doing wrong, have spend lot of time on this, in advance.

if run application on android platform, think need resolve native uri. can use this plugin resolve it.

example:

window.filepath.resolvenativepath(yournativeuri,                 function (result) {                     console.log('resolving file path: ' + result);                                         }, function (error) {                     console.log(error);                 }); 

Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -