我在ios中使用cordovaFileTransfer.download(url, targetPath2, {}, true)
下载了一个图片。它显示成功,但图像在设备上不可用。如何解决此问题。
这是我的代码: -
$scope.Download = function () {
ionic.Platform.ready(function(){
var url = "https://www.google.co.in//images/branding/googlelogo/2x/googlelogo_color_120x44dp.png";
var filename = url.split("/").pop();
var targetPath2 = cordova.file.dataDirectory + 'Pictures/' + filename;
alert(targetPath2);
$cordovaFileTransfer.download(url, targetPath2, {}, true).then(function (result) {
alert(JSON.stringify(result));
$scope.hasil = 'Save file on '+targetPath2+' success!';
$scope.mywallpaper=targetPath2;
alert( $scope.hasil);
alert($scope.mywallpaper);
}, function (error) {
$scope.hasil = 'Error Download file';
}, function (progress) {
$scope.downloadProgress = (progress.loaded / progress.total) * 100;
alert("dom"+$scope.downloadProgress);
});
});
}