我收到以下错误:
ReferenceError: FileTransfer is not defined
Run Code Online (Sandbox Code Playgroud)
当我尝试创建一个新实例时:
var ft = new FileTransfer();
Run Code Online (Sandbox Code Playgroud)
使用Linux上的PhoneGap进行开发(debian)插件文件和文件传输添加了corse
资源:
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);
Run Code Online (Sandbox Code Playgroud)
在此示例中,服务器的URL无效.
正在显示第1和第2个警报.
在apache访问或错误日志中没有在服务器上记录上载请求
Param imageURI是正确的并通过函数参数传递(不是此源的一部分)
PhoneGap版本3.1.0
Roe*_*umi 29
你添加了'文件'或'文件传输'插件吗?
Filetransfer插件是一个单独的插件,您需要添加它们:
cordova plugin add cordova-plugin-file-transfer
Run Code Online (Sandbox Code Playgroud)
否则,'FileTransfer'确实没有定义.希望有所帮助....