我想将捕获的图像从 android 手机上传到 Ftp 服务器我已经编写了以下代码我在这行 ftp.store(remote,input) 处遇到错误我在使用 apache commons-net 3.3 库获取回复代码 = 550 文件后无法使用我我
在.net中尝试过与WebClient相同的操作,但在java中它给了我dis错误(550)我已经搜索了很多网站但没有帮助我什至打电话给托管服务他们说从那里没有问题我从最后一天卡住了plz纠正我我在这里缺少的东西......
我的代码:
private void UploadImage(){
FTPClient ftp = new FTPClient();
try {
ftp.connect("hostname",21);// Using port no=21
int reply = ftp.getReplyCode(); //here i m getting 220
ftp.login("abc", "abc");
reply = ftp.getReplyCode(); //here i m getting 230
ftp.setFileType(FTP.BINARY_FILE_TYPE);
reply = ftp.getReplyCode();
ftp.enterLocalPassiveMode();
reply = ftp.getReplyCode();
File sfile = new File(PhotoPath); //here i m getting /mnt/sdcard/DCIM/CameraSample/abc769708880.jpg
String filename = sfile.getName();
FileInputStream fis = new FileInputStream(sfile);
boolean aRtn=ftp.storeFile("ftpPath"+sfile.getName(), fis);// return true if successful
reply = ftp.getReplyCode(); // here im getting 550
if(aRtn == true)
{
Toast toast= Toast.makeText(getApplicationContext(),
"Successfull", Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.CENTER, 0, 0);
toast.show();
}
fis.close();
ftp.disconnect();
} catch (SocketException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}