Created
April 1, 2016 13:42
-
-
Save sidthesloth92/a97e483726c7c83e6688d5716737a3e7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment