我有以下代码,使用ftp host:ftp.aydeena.com
但不想将文件上传到根目录。因为我想将它上传到以下路径:
ftp.aydeena.com/facebook/profileimages/
我该怎么做?
FTPClient con = new FTPClient();
String status="";
try{
con.connect("ftp.aydeena.com");
if (con.login("user", "pass")){
con.enterLocalPassiveMode(); // important!
con.changeWorkingDirectory("/facebook/profileimages/");
String data = "test data";
ByteArrayInputStream in = new ByteArrayInputStream(data.getBytes());
boolean result = con.storeFile(Path, in);
in.close();
if (result) Log.v("upload result", "succeeded");
status ="succeeded" ;
con.logout();
con.disconnect();
}
}
catch (Exception e){
e.printStackTrace();
status= "Error : "+e.getMessage();
}