ftp_login在第二次尝试登录时失败?

时间:2019-12-05 13:42:38

标签: php ftp

我正在尝试通过FTP下载大量文件。这会导致

的奇怪警告

Warning: ftp_get(): Getting data connection.

我的解决方案是使用ftp_close注销,然后重新登录,代码如下所示,但是,这会导致

的警告

Warning: ftp_login(): User name okay, need password

问题是当我收到先前的警告时,我使用的用户名和密码是完全相同的,并且到目前为止,我已经下载了数十个文件,因此用户名和密码是正确的。我也有代码打印凭据,以确认它们是正确的并且存在。还有其他人处理过这种警告组合吗?

我用来登录的代码。

        //Attempt to connect and login to the server
        if (!$this->oFTP = ftp_connect($this->cHost)) {
            exit("\n<br>COULD NOT CONNECT TO SERVER: $this->cHost");
        } else {
            echo "\n<br>CONNECTION SUCESSFUL: $this->cHost";
            if(!ftp_login($this->oFTP, $this->cFtpUserName, $this->cFtpUserPass)){
                exit("\n<br>LOGIN FAILURE!: $this->cFtpUserName, $this->cFtpUserPass");
            } else {
                echo "\n<br>LOGIN SUCESSFUL: $this->cFtpUserName";
            }
        }

        //Make sure we are using the correct ip address
        ftp_set_option($this->oFTP, FTP_USEPASVADDRESS, false);

        //Allows us to retrive files
        ftp_pasv($this->oFTP,true);

编辑:

在询问了有关此内容之后,我回头查看了连接日志,看起来实际上可能没有通过ftp_get获取任何文件。我有另一个脚本,该脚本使用相同的登录凭据运行完全相同的功能,因此我知道它正在工作。如果在同一时间运行,那会是个问题吗?

0 个答案:

没有答案