【发布时间】:2016-02-09 20:06:33
【问题描述】:
我正在尝试通过使用 phonegap 文件传输插件下载方法从 url 下载图像
但总是得到错误代码:3,
这是我的代码:
window.requestFileSystem(window.LocalFileSystem.PERSISTENT, 0, function(fs)
{
// create the download directory is doesn't exist
fs.root.getDirectory('download', { create: true });
// save file in .. download
var filePath = fs.root.fullPath + 'download/' + url.split('/').pop();
var fileTransfer = new FileTransfer();
var uri = encodeURI(decodeURIComponent("http://phonegap.com/uploads/artwork/Build-Bot-Preview.png"));
filePath="file:///sdcard"+filePath;
fileTransfer.download(uri,filePath,function(entry)
{
alert("Successfully downloaded file, full path is " + entry.fullPath);
},
function(error)
{
alert("Some error " + error.code + " for " + url);
},
false);
});
谢谢。
【问题讨论】:
标签: android cordova download phonegap-plugins file-transfer