`console.log(sourceType);
var options = {
quality: 60,
destinationType: Camera.DestinationType.FILE_URI,
encodingType: Camera.EncodingType.JPEG,
sourceType: sourceType,
saveToPhotoAlbum: false
};
console.log(options);
$scope.hidePopup = false;
$scope.functionCalled = true;
$cordovaCamera.getPicture(options).then(function(imagePath) {
console.log(imagePath);
// Grab the file name of the photo in the temporary directory
var currentName = imagePath.replace(/^.*[\\/]/, '');
//Create a new name for the photo
var d = new Date(),
n = d.getTime(),
newFileName = n + ".jpg";
// If you are trying to load image from the gallery on Android we need special treatment!
if ($cordovaDevice.getPlatform() == 'Android' && sourceType === Camera.PictureSourceType.PHOTOLIBRARY) {
window.FilePath.resolveNativePath(imagePath, function(entry) {
window.resolveLocalFileSystemURL(entry, success, fail);
function fail(e) {
console.error('Error: ', e);
}
function success(fileEntry) {
var namePath = fileEntry.nativeURL.substr(0, fileEntry.nativeURL.lastIndexOf('/') + 1);
// Only copy because of access rights
$cordovaFile.copyFile(namePath, fileEntry.name, cordova.file.dataDirectory, newFileName).then(function(success) {
$scope.image = newFileName;
$scope.uploadImage('profile_pic', $scope.image);
}, function(error) {
$scope.showAlert('Error', error.exception);
});
};
});
} else {
var namePath = imagePath.substr(0, imagePath.lastIndexOf('/') + 1);
// Move the file to permanent storage
$cordovaFile.moveFile(namePath, currentName, cordova.file.dataDirectory, newFileName).then(function(success) {
$scope.image = newFileName;
$scope.uploadImage('profile_pic', $scope.image);
}, function(error) {
$scope.showAlert('Error', error.exception);
});
}
// if(!$scope.hidePopup && $scope.functionCalled){
// $scope.showAlert('Success','Permited size exceeded');
// }
},
function(err) {
// Not always an error, maybe cancel was pressed...
})
};`
I'm able to get the first console message but not the one printing imagePath & also not getting any error message. Issue is only there in phones having android 4.4.X & on iPhone as well.
`console.log(sourceType); var options = { quality: 60, destinationType: Camera.DestinationType.FILE_URI, encodingType: Camera.EncodingType.JPEG, sourceType: sourceType, saveToPhotoAlbum: false }; console.log(options); $scope.hidePopup = false; $scope.functionCalled = true; $cordovaCamera.getPicture(options).then(function(imagePath) { console.log(imagePath); // Grab the file name of the photo in the temporary directory var currentName = imagePath.replace(/^.*[\\/]/, '');
I'm able to get the first console message but not the one printing imagePath & also not getting any error message. Issue is only there in phones having android 4.4.X & on iPhone as well.