嗨我手机磁盘上有一个xml文件。我想把它上传到服务器。我实现了它,但问题是xml文件在服务器中时是空的。下面的函数运行正常,我的意思是xml文件正确上传到服务器,但它是空的。为什么呢?
private void uploadXmlFile(int levelID){
String FTP_HOST= "181.50.149.1";
String FTP_USER = "kdirrrri";
String FTP_PASS ="123456";
File f = new File(Environment.getExternalStorageDirectory()+"/kadirgame/"+levelID+".xml");
FTPClient client = new FTPClient();
try {
client.connect(FTP_HOST,21);
client.login(FTP_USER, FTP_PASS);
client.setType(FTPClient.TYPE_BINARY);
client.changeDirectory("/levels/");
// client.upload(f);
client.upload(f, new MyTransferListener());
} catch (Exception e) {
e.printStackTrace();
try {
client.disconnect(true);
} catch (Exception e2) {
e2.printStackTrace();
}
}
}