Download/Save a URL Image file to Photo Gallery for iOS


#1

I have been trying to download a URL Image file to the photo gallery on iOS. but it ends with an permission error. have a look at my code that am using to store image.

$scope.Download = function (imgurl) {
$ionicPlatform.ready(function(){
var url = imgurl;
var filename = url.split("/").pop();
var targetPath = cordova.file.documentsDirectory + filename;
console.log(cordova.file.documentsDirectory);
$cordovaFileTransfer.download(url, targetPath, {}, true).then(function (result) {
$scope.hasil = ‘Save file on ‘+targetPath+’ success!’;
$ionicLoading.hide();
$scope.mywallpaper=targetPath;
}, function (error) {
$scope.hasil = ‘Error Download file’;
}, function (progress) {
$scope.downloadProgress = (progress.loaded / progress.total) * 100;
});
});
};
if am wrong on any point. please let me know.
Thanks for the help.