我尝试将图片上传到我的服务器,但是当我试图打开此图片时 - 它无法打开,显然是因为它已损坏。有人能帮帮我,告诉我为什么吗?谢谢!
我使用的是Apache Commons Net jar。
String hostName = "host";
String username = "username";
String password = "pass";
String location = "filePath.png";
FTPClient ftp = null;
InputStream in = null;
try {
ftp = new FTPClient();
ftp.connect(hostName);
ftp.login(username, password);
ftp.changeWorkingDirectory("/pictures");
int reply = ftp.getReplyCode();
System.out.println("Received Reply from FTP Connection:" + reply);
if(FTPReply.isPositiveCompletion(reply))
{
System.out.println("Connected Success");
}
ftp.setFileType(FTP.BINARY_FILE_TYPE);
File f1 = new File(location);
in = new FileInputStream(f1);
ftp.storeFile("fileName.png",in);
System.out.println("SUCCESS");
in.close();
ftp.logout();
ftp.disconnect();
} catch (Exception e) {
e.printStackTrace();
}
答案 0 :(得分:0)
我的防病毒软件阻止了它..