Phonegap:从SD卡获取文件并将其上传到android中的FTP服务器

时间:2014-03-20 05:22:26

标签: android cordova ftp phonegap-plugins

我是关于phonegap开发的新手。在我的应用程序中有一个按钮,点击该按钮将打开 sdcard 的目录结构,并选择一个文件,选择的文件将上传到 FTP服务器

我尝试了这个链接 ftpclient ,但它没有指定如何打开目录结构并选择文件,它根本不起作用。

任何人都可以给我正确的步骤或上述解决方案。谢谢。

1 个答案:

答案 0 :(得分:1)

以下是FileChooser的插件,可让您选择从SDCard中选择文件。 cordova-filechooser。请更改filechooser.js这样的文件

(function( cordova ) {

function FileChooser() {}

    FileChooser.prototype.open = function(win, fail) {
        return cordova.exec(
            function (args) { if(win !== undefined) { win(args); } },
            function (args) { if(fail !== undefined) { fail(args); } },
            "FileChooser", "open", []);
    };

    if(!window.plugins) {
        window.plugins = {};
    }

    if (!window.plugins.FileChooser) {
        window.plugins.FileChooser = new FileChooser();
    }

})( window.cordova );

js文件夹中添加此js文件。并像这样使用

plugins.FileChooser.open(function (uri) {
                // success
            alert(uri); 

            },function () {
               // fail
                alert('failed');
            });