我有一個文件夾上的Android設備,我想上傳到我的服務器。我怎樣才能上傳整個文件夾到服務器在android
在服務器端使用PHP。
它可以是FTP或任何其他選項..
(呵呵,我也要做一個服務裏面)..
我有一個文件夾上的Android設備,我想上傳到我的服務器。我怎樣才能上傳整個文件夾到服務器在android
在服務器端使用PHP。
它可以是FTP或任何其他選項..
(呵呵,我也要做一個服務裏面)..
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", "[email protected]"); //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);
但它的一個文件夾內。在此代碼你上傳的文件..'/ SD卡/ vivekm4a.m4a' .. – NirPes