【发布时间】:2017-10-17 18:18:51
【问题描述】:
我正在尝试使用 Apache FTPClient 将图片从三星上传到 FTP 服务器。但这似乎不起作用。我不知道为什么,代码很好。我正在尝试选择一张图片上传到服务器上,selectedImage变量是图片文件的完整路径。
FTPClient ftpClient = new FTPClient();
ftpClient.connect(InetAddress.getByName("ftpserver"));
ftpClient.login("user", "password");
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
FileInputStream buffIn = null;
buffIn = new FileInputStream(new File(getRealPathFromURI(selectedImage)));
ftpClient.enterLocalPassiveMode();
link = "http://ftpname/home/user/public_html/image/ayri.jpg";
ftpClient.storeFile(link, buffIn);
buffIn.close();
ftpClient.logout();
ftpClient.disconnect();
【问题讨论】:
标签: java android ftp apache-commons-net