无法保存到Android和Apache Cordova 3.4.1上的文件
Cordova版本:3.4.1-0.1.0 我正在使用文件传输插件,无法将图像保存到文件中 从设备中获取的错误: “下载错误目标错误” 上传错误代码1 这是代码,有什么想法吗无法保存到Android和Apache Cordova 3.4.1上的文件,android,cordova,Android,Cordova,Cordova版本:3.4.1-0.1.0 我正在使用文件传输插件,无法将图像保存到文件中 从设备中获取的错误: “下载错误目标错误” 上传错误代码1 这是代码,有什么想法吗 var fileTransfer = new FileTransfer(), d = new Date(), testImageUrl = encodeURI('http://www.inutritie.ro/wp-content/uploads/2013/07/otet-600x300.jpg'),
var fileTransfer = new FileTransfer(),
d = new Date(),
testImageUrl = encodeURI('http://www.inutritie.ro/wp-content/uploads/2013/07/otet-600x300.jpg'),
imageCacheDir = '//Testdir';
fileTransfer.download(
testImageUrl,
'file:'+imageCacheDir+'/'+d.getTime(),
function(entry){
alert("download complete: " + entry.fullPath);
},
function(error){
alert("download error source " + error.source);
alert("download error target " + error.target);
alert("upload error code" + error.code);
}
);
以下是我如何设置并获取将图像保存到Android设备上的目录:
function initLocalCacheDir(){
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, onFileSystemFail);
};
function onFileSystemSuccess(fileSystem) {
fileSystem.root.getDirectory("Testdir",{create:true, exclusive: false}, gotDir, gotDirError);
};
function gotDir(d) {
var imageCacheDir = d.fullPath;
};
function gotDirError(evt) {
alert('gotDirError');
};
function onFileSystemFail(evt) {
alert('onFileSystemFail');
};
Testdir存在吗?在保存文件之前,保存文件的目录必须存在。它不会为你创造它。