phonegap“new FileTransfer” “未定义” [英] phonegap "new FileTransfer" "is not defined"

查看:681
本文介绍了phonegap“new FileTransfer” “未定义”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误:

  ReferenceError:FileTransfer未定义

  

> var ft = new FileTransfer();

在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);
pre>

服务器的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆