Solve the problem that the file uploaded by ftpclient is empty and 0 bytes are displayed

Java is always empty when uploading files using ftpclient, but not when using FileZilla client.

Later, after checking the information, the FTP server has passive mode and active mode. (refer to other information for details)

Setting ftpclient to passive mode in Java can solve the problem.

Supplement:

Call ftpclient enterLocalPassiveMode(); This method means that before each data connection, the FTP client tells the FTP server to open a port to transmit data. Why do you want to do this? FTP server may open different ports to transmit data every time, but on Linux, due to security restrictions, some ports may not be opened, so blocking occurs.

This problem is solved successfully!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>