2016-11-03 4 views

Antwort

0

Um das zu erreichen, müssen Sie die Datei in Ihren lokalen Speicher kopieren. Dafür müssen Sie das Datei-Plugin für copyFile verwenden. Bitte überprüfen Sie den folgenden Code. Ich hoffe, das wird für dich funktionieren.

angular.module('starter', ['ionic', 'ngCordova']) 

.run(function($ionicPlatform) { 
    $ionicPlatform.ready(function() { 
    //you app code goes here 
    }); 
}) 
.controller('FileController', function($scope, $cordovaCamera, $cordovaFile) { 
    $scope.fileName = ""; 
    $scope.uploadPicture = function() { 
    var options = { 
     quality: 50, 
     destinationType: Camera.DestinationType.FILE_URI, 
     sourceType: Camera.PictureSourceType.CAMERA, 
     allowEdit: true, 
     encodingType: Camera.EncodingType.JPEG, 
     targetWidth: 1024, 
     targetHeight: 768, 
     popoverOptions: CameraPopoverOptions, 
     saveToPhotoAlbum: false, 
     correctOrientation: true 
    }; 

    $cordovaCamera.getPicture(options).then(function(sourcePath) { 
     var sourceDirectory = sourcePath.substring(0, sourcePath.lastIndexOf('/') + 1); 
     var sourceFileName = sourcePath.substring(sourcePath.lastIndexOf('/') + 1, sourcePath.length); 

     console.log("Copying from : " + sourceDirectory + sourceFileName); 
     console.log("Copying to : " + cordova.file.dataDirectory + sourceFileName); 
     $cordovaFile.copyFile(sourceDirectory, sourceFileName, cordova.file.dataDirectory, sourceFileName).then(function(success) { 
     $scope.fileName = cordova.file.dataDirectory + sourceFileName; 
     }, function(error) { 
     console.dir(error); 
     }); 

    }, function(err) { 
     console.log(err); 
    }); 
    } 
}); 

Dank ..

+0

hallo hiro, habe ich versucht, den Code, der euch gesandt, aber es funktioniert nicht. – pdixit

+0

Hallo Hiro bt nach dem Kopieren, wie kann ich die Bilder aus diesem Datenverzeichnis Ordner holen, die ich leicht mit dem lokalen Speicher tun kann – pdixit

Verwandte Themen