我试图在FTP服务器中保存图像。但是它给出了像java.io.IOException这样的错误:FTP错误:553无法创建文件。
我称之为方法 上传(" xxx.xx.2.36""名为ftpuser"" xxxxxpos",镜像文件," ftp://ftpuser@xxx.xx.2.36/Item/&#34) ;
public static void check(FTPClient ftp, String cmd, boolean succeeded) throws IOException {
if (!succeeded) {
throw new IOException("FTP error: " + ftp.getReplyString());
}
}
/**
*
* @return
*/
private static String today() {
return new SimpleDateFormat("yyyy-MM-dd").format(new Date());
}
public static void upload(String server, String username, String Password,
File imageFile, String destDir) {
FTPClient ftp = new FTPClient();
try {
ftp.connect(server);
check(ftp, "login", ftp.login(username, Password));
System.out.println("Connected to " + server + ".");
InputStream input = new FileInputStream(imageFile);
try {
String destination = destDir;
if (destination.endsWith("/")) {
destination += today()+"-"+imageFile.getName();
System.out.println("direc" +destination);
}
check(ftp, "store", ftp.storeFile(destination, input));
System.out.println("Stored " + imageFile + " to " + destination + ".");
} finally {
input.close();
}
check(ftp, "logout", ftp.logout());
}catch(Exception e){
e.printStackTrace();
}
finally {
try {
ftp.disconnect();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
在ftp.storeFile(目的地,输入)之后,它给出了错误
请帮助解决这个问题。