Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/225.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android中将整个文件夹上载到服务器_Android_Upload_Ftp_Android Service_Httprequest - Fatal编程技术网

如何在android中将整个文件夹上载到服务器

如何在android中将整个文件夹上载到服务器,android,upload,ftp,android-service,httprequest,Android,Upload,Ftp,Android Service,Httprequest,我在android设备上有一个文件夹,我想上传到我的服务器上 在服务器端使用PHP 它可以是FTP或任何其他选项 (哦,我必须在服务内部进行)是的,你说得对 对于文件夹,请尝试以下操作: 但它是一个文件夹。。在此代码中,您正在上载一个文件/sdcard/vivekm4a.m4a.well。。我怎样才能有目的地去做呢?(我必须在服务内部完成) USE THIS : public void goforIt(){ FTPClient con = null; try {

我在android设备上有一个文件夹,我想上传到我的服务器上

在服务器端使用PHP

它可以是FTP或任何其他选项

(哦,我必须在服务内部进行)

是的,你说得对

对于文件夹,请尝试以下操作:


但它是一个文件夹。。在此代码中,您正在上载一个文件<代码>/sdcard/vivekm4a.m4a.well。。我怎样才能有目的地去做呢?(我必须在服务内部完成)
USE THIS :

public void goforIt(){


    FTPClient con = null;

    try
    {
        con = new FTPClient();
        con.connect("192.168.2.57"); //Your server IP

        if (con.login("Administrator", "KUjWbk")) //Your Login Creadentials
        {
            con.enterLocalPassiveMode(); // important!
            con.setFileType(FTP.BINARY_FILE_TYPE);
            String data = "/sdcard/vivekm4a.m4a";    

            FileInputStream in = new FileInputStream(new File(data));
            boolean result = con.storeFile("/vivekm4a.m4a", in);
            in.close();
            if (result) Log.v("upload result", "succeeded");
            con.logout();
            con.disconnect();
        }
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
Intent intent = new Intent();
intent.setAction(Intent.ACTION_PICK);
// FTP URL (Starts with ftp://, sftp:// or ftps:// followed by hostname and port).
Uri ftpUri = Uri.parse("ftp://yourftpserver.com");
intent.setDataAndType(ftpUri, "vnd.android.cursor.dir/lysesoft.andftp.uri");
// FTP credentials (optional)
intent.putExtra("ftp_username", "anonymous");
intent.putExtra("ftp_password", "something@somewhere.com");
//intent.putExtra("ftp_keyfile", "/sdcard/dsakey.txt");
//intent.putExtra("ftp_keypass", "optionalkeypassword");
// FTP settings (optional)
intent.putExtra("ftp_pasv", "true");
//intent.putExtra("ftp_resume", "true");
//intent.putExtra("ftp_encoding", "UTF8");
// Upload
intent.putExtra("command_type", "upload");
// Activity title
intent.putExtra("progress_title", "Uploading folder ...");
intent.putExtra("local_file1", "/sdcard/localfolder");
// Optional initial remote folder (it must exist before upload)
intent.putExtra("remote_folder", "remotefolder/uploadedfolder");
startActivityForResult(intent, 2);