Cordova Phonegap(iOS) - 如何将图像文件从URL下载到iOS图像库

时间:2014-10-20 02:13:27

标签: ios iphone cordova

我试过这个,它适用于Android手机。在iOS中,我可以显示“图像已下载”警报,但我在iPhone图像库中找不到该图像。

var path = 'http://example.com';

if( navigator.connection.type == Connection.NONE ) {
  navigator.notification.alert('unable to download an image due to disconnect network.');
  return;
} else {
  var uri = encodeURI(path);
  var fileName = path.split('/').pop();
  var filePath = fileSystem.root.toURL() + fileName;
  var fileTransfer = new FileTransfer();

  fileTransfer.download(uri, filePath, function(entry){
    navigator.notification.alert( 'The Image has been downloaded.')
  });
}

0 个答案:

没有答案