你问我所有我试图上传一个像4mb的小文件或者什么与apache commons ftpclient它不上传我的文件并且没有给我任何错误并说上传成功 这是我的代码,请提前帮助我。 这里是代码..
new Thread(new Runnable() {
public void run() {
Looper.prepare();
FTPClient client = new FTPClient();
try {
boolean result = false;
FileInputStream fis = null;
client.connect(server);
client.enterLocalPassiveMode();
client.login(user, pass);
client.makeDirectory("/public_html/"+str); ///str is a name of remote folder
client.setFileType(FTP.BINARY_FILE_TYPE);
client.setFileTransferMode(FTP.BINARY_FILE_TYPE );
client.changeWorkingDirectory(str);
String path1 = Environment.getExternalStorageDirectory() + "/index.htm";
File f = new File(path1);
String testname = f.getName();
fis = new
FileInputStream(f);
result = client.storeFile(testname, fis);
if (result == true){
Log.v("upload","upload successfull");
}
else{
Log.v("upload", "upload failed");
}
catch (Exception e) {
e.printStacktrace();
}
}
}).start();
答案 0 :(得分:1)
client.changeWorkingDirectory(str);
可能str
目录不存在,因为您创建的目录是"/public_html/"+str
。