未捕获的ReferenceError:未定义文件传输(使用科尔多瓦2.7.0) [英] Uncaught ReferenceError: FileTransfer is not defined (using cordova 2.7.0)
本文介绍了未捕获的ReferenceError:未定义文件传输(使用科尔多瓦2.7.0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用文件传输下载从Web服务器,code文件是如下:
I want to use FileTransfer to download a file from web server, code is as following:
function downloadFile(url) {
var fileTransfer = new FileTransfer();
var uri = encodeURI(url);
var filepath="www/download/";
fileTransfer.onprogress = function(progressEvent) {
if (progressEvent.lengthComputable) {
loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total);
} else {
loadingStatus.increment();
}
};
fileTransfer.download(
uri,
filePath,
function(entry) {
console.log("download complete: " + entry.fullPath);
},
function(error) {
console.log("download error source " + error.source);
console.log("download error target " + error.target);
console.log("upload error code" + error.code);
},
false,
{
headers: {
}
}
);
}
当我运行我在模拟器或实devide,全部命中错误信息的应用程序:未捕获的ReferenceError:文件传输没有定义
when I run my app in simulator or real devide, all hit error message: Uncaught ReferenceError: FileTransfer is not defined.
我已经包括cordova.js,什么是此错误的原因是什么?谢谢。
I have included cordova.js, what is the reason for this error? thanks.
RGDS
布伦特
rgds brent
推荐答案
您需要安装的PhoneGap插件:
You need to install phonegap plugin:
$phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git
$phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer.git
如果您已经安装,可能需要重新构建PhoneGap的平台:
If you already install, probably you need rebuild phonegap platforms:
$phonegap build android
这篇关于未捕获的ReferenceError:未定义文件传输(使用科尔多瓦2.7.0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文