简体   繁体   English

未捕获的参考错误:cordova.js(3.0.0)中未定义FileTransfer

[英]uncaught reference error: FileTransfer not defined at cordova.js(3.0.0)

I am bulding a simple cross platform app using cordova 3.0.0. 我正在使用Cordova 3.0.0构建一个简单的跨平台应用程序。 The installation went fine. 安装正常。 But I cannot seem to get the file transfer to work. 但是我似乎无法使文件传输正常工作。 I keep getting this error. 我不断收到此错误。 processMessage failed: Error: ReferenceError: FileTransfer is not defined at file:///android_asset/www/cordova.js:1035

I have installed all the plugins properly and also calling device ready as such: 我已经正确安装了所有插件,并且还这样调用了设备:

function onLoad(){
        document.addEventListener("deviceready",onDeviceReady,false);
}

My code is as follows: 我的代码如下:

function uploadFileForCapture(mediaFile) {
        var ftforcapture = new FileTransfer(),
            path = mediaFile.fullPath,
            name = mediaFile.name;
            alert(path + name);
        ftforcapture.upload(path,
            "http:/some.server.com/upload.php",
            function(result) {
                alert('Upload success: ' + result.responseCode);
                alert(result.bytesSent + ' bytes sent');
            },
            function(error) {
                alert('Error uploading file ' + path + ': ' + error.code);
            },
            { fileName: name });
    }

Can some one please help! 有人可以帮忙吗? Thanks a lot in advance! 在此先多谢!

I ran into this error as well. 我也遇到了这个错误。 For me the file transfer plugin was never successfully installed. 对我而言,文件传输插件从未成功安装。 It was not in the android platform folder with the other plugins that I was using. 它不在我使用的其他插件的android平台文件夹中。 I was installing with the cli client. 我正在使用cli客户端进行安装。 I created a fresh project and noticed that when I ran this cordova plugin add command that I received this error. 我创建了一个新项目,并注意到当我运行此cordova插件添加命令时收到此错误。

[TypeError: Arguments to path.join must be strings] [TypeError:path.join的参数必须为字符串]

I tried a clean install on a virtual machine expecting it to be something in my setup but it still didn't work. 我尝试在虚拟机上进行全新安装,希望它可以在我的安装程序中运行,但仍然无法正常工作。 Before I could file a bug report on it, Cordova 3.1.0 was released. 在我可以对此提交错误报告之前,Cordova 3.1.0已发布。 I created my project over and this time the file transfer plugin was successfully installed. 我创建了我的项目,这一次成功安装了文件传输插件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM