phonegap“new FileTransfer” “未定义” [英] phonegap "new FileTransfer" "is not defined"
问题描述
我收到以下错误:
ReferenceError:FileTransfer未定义
> var ft = new FileTransfer();
在Linux上使用PhoneGap开发(debian)
插件文件&文件传输添加corse
源:
var options = new FileUploadOptions();
pre>
options.chunkedMode = false;
options.fileKey =file;
options.fileName = imageURI.substr(imageURI.lastIndexOf('/')+ 1);
options.mimeType =text / plain;
var params = new Object();
params.value1 =test;
params.value2 =filename;
options.params = params;
try {
var ft = new FileTransfer();
}
catch(e){
alert(ERR =+ e);
}
alert(I =+ imageURI);
ft.upload(imageURI,http://test.com/upload.php),win,fail,options,true);
服务器的URL在此示例中无效。
正在显示第一和第二警报。
在apache访问或错误日志中,服务器上没有上传请求
Param imageURI是正确的,函数参数(不是此源的一部分)
PhoneGap版本3.1.0
解决方案您添加了文件或文件传输插件吗?
Filetransfer插件是一个单独的插件,您需要添加这两个插件:
cordova插件add cordova-plugin-file-transfer
否则,'FileTransfer'确实没有定义。
希望有帮助....I get the following error:
ReferenceError: FileTransfer is not defined
when i try to create a new instance:
var ft = new FileTransfer();
Developing with PhoneGap on Linux (debian) Plugins file & file-transfer added of corse
Source:
var options = new FileUploadOptions(); options.chunkedMode = false; options.fileKey = "file"; options.fileName = imageURI.substr(imageURI.lastIndexOf('/')+1); options.mimeType = "text/plain"; var params = new Object(); params.value1 = "test"; params.value2 = "filename"; options.params = params; try { var ft = new FileTransfer(); } catch (e) { alert("ERR = "+e); } alert("I = "+imageURI); ft.upload(imageURI, http://test.com/upload.php"), win, fail, options, true);
URL of server is no valid in this example.
The 1st and 2nd alert are being displayed.
No upload request logged on the server in apache access or error logs
Param imageURI is correct and passed via function param (not part of this source)
PhoneGap Version 3.1.0
解决方案Did you add the 'file' or 'file-transfer' plugin?
The Filetransfer plugin is a separate plugin, and you need to add both of them:
cordova plugin add cordova-plugin-file-transfer
Otherwise, the 'FileTransfer' is indeed not defined. Hope that helps....
这篇关于phonegap“new FileTransfer” “未定义”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!