0
我是PhoneGap App开发的新手。 使用Android 4.1.2使用cordova-2.6.0。 这里有什么问题? 谁能帮我做这个....如何修复PhoneGap上的错误代码1 FileTransfer()
function photoDownload(url, target) {
var url = encodeURI(url);
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fs) {
var imagePath = fs.root.fullPath + "/" + target; // full file path
// fs.root.fullPath returns "file:///storage/sdcard0/"
//var imagePath = "/storage/sdcard0/" + target; // try another full file path
var fileTransfer = new FileTransfer();
fileTransfer.download(
url,
imagePath,
function (entry) {
alert("success" + entry.fullPath); // entry is fileEntry object
},
function (error) {
alert("error source " + error.source);
alert("error target " + error.target);
alert("error code " + error.code);
},
true,
{
headers: {}
}
);
})
}
它返回错误代码1,这意味着未找到文件。但我尽我所能。
<div style="font-size: 22px;" onclick="photoDownload('url', 'save');">Download</div><br/><br/>
<div style="font-size: 22px;" onclick="photoDownload('http://aponblog.com/inc/images/globe.png', 'globe.png');">Download</div><br/>
<div style="font-size: 22px;" onclick="photoDownload('http://aponblog.com/inc/images/globe.png', 'TestFolder/globe.png');">TestFolder/Download</div><br/><br/>
<div style="font-size: 22px;" onclick="photoDownload('https://graph.facebook.com/simplyapon/picture?width=100&height=100', 'simplyapon.jpg');">S Download</div><br/>
<div style="font-size: 22px;" onclick="photoDownload('https://graph.facebook.com/simplyapon/picture?width=100&height=100', 'TestFolder/simplyapon.jpg');">S TestFolder/Download</div><br/>