这是我的代码:
图片存在于http://www.google.com/trends/resources/2327917647-google-icon.png
我无法保存图片
它显示错误代码1 有什么问题?
function gfsuccess(fentry){
alert(fentry.fullPath+"dircreated")
var fileTransfer = new FileTransfer();
var uri = encodeURI("http://www.google.com/trends/resources/2327917647-google-icon.png");
fileTransfer.download(uri,fentry.fullPath+"/newimg.png", // //demo_folder
function(entry) {
alert("download complete: " + entry.toURL());
},
function(error) {
alert("download error source " + error.source);
console.log("download error target " + error.target);
console.log("upload error code" + error.code);
},
false, {
headers: {
"Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
}
});
}
function gotfs(fs){
alert("gotfs"+fs);
fs.root.getDirectory("demo_folder", {create: true, exclusive: false},gfsuccess,errorHandler);
}
function errorHandler(e){
alert("Files system error"+e.code);
}
function onDeviceReady() {
alert("device ready"+navigator.connection.type);
//external root dir: file:///storage/sdcard0/
window.requestFileSystem(LocalFileSystem.PERSISTENT, 20*1024*1024/*5MB*/, gotfs, errorHandler);
}
function domLoaded(){
alert("dom loaded");
document.addEventListener("deviceready", onDeviceReady, false);
}
文件夹创建正常,但我似乎无法获得图像..不知道这里发生了什么