Hãy tìm hiểu điều này. Mã chạy đúng mà không có ngoại lệ.FtpClient storeFile luôn trả về False
FTPClient ftp = new FTPClient();
ftp.connect(server);
if(!ftp.login(username, password))
{
ftp.logout();
return false;
}
int reply = ftp.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply))
{
ftp.disconnect();
return false;
}
InputStream in = new FileInputStream(localfile);
ftp.setFileType(ftp.BINARY_FILE_TYPE, ftp.BINARY_FILE_TYPE);
ftp.setFileTransferMode(ftp.BINARY_FILE_TYPE);
Store = ftp.storeFile(destinationfile, in);
in.close();
ftp.logout();
ftp.disconnect();
}
catch (Exception ex)
{
ex.printStackTrace();
return false;
}
return Store;
Buttttttttt
lệnh return luôn trả về false và các tập tin không được tải lên trên máy chủ. Một số xin vui lòng giúp đỡ về điều này.
Để biết thông tin của bạn, 1) tôi đang ở trong mạng văn phòng. ---> chúng ta có cần thêm bất kỳ proxy nào không?
File file = new File("C:\\Users\\sg0214273\\Desktop\\seagate\\seagate.txt");
FileInputStream input = new FileInputStream(file);
client.setFileType(FTP.BINARY_FILE_TYPE);
if (!client.storeFile(file.getName(), input)) {
System.out.println("upload failed!");
}
reply = client.getReplyCode();
if(!FTPReply.isPositiveCompletion(reply)) {
System.out.println("upload failed!");
}
Login success...
230 User ******** logged in.
upload failed!-----> is form boolean return value of storefile
upload failed!---------> is from replycode...
Logout from FTP server...
hãy giúp đỡ
ftp.getReplyCode() trả về gì? Sau ftp.storeFile? –
@Gray no.Nhìn vào câu đầu tiên –