正常情况下,默认使用主动模式 连接ftp;如果ftp仍然是登陆成功但是没有上传或下载文件,就在登陆后加入一行代码,客户端使用被动方式连接ftp服务端
ftpC.login(user, password);
// ftpC.enterLocalPassiveMode();
if (null != remotePath) {
// 打开进入指定目录
ftpC.changeWorkingDirectory(remotePath);
}
ftpC.login(user, password);
// ftpC.enterLocalPassiveMode();
if (null != remotePath) {
// 打开进入指定目录
ftpC.changeWorkingDirectory(remotePath);
}
本文介绍了一种解决FTP连接问题的方法,即当默认的主动模式无法完成文件上传或下载时,如何通过简单的代码调整来启用被动模式,从而确保FTP操作正常进行。
1294

被折叠的 条评论
为什么被折叠?



