PHP - 无法连接到FTP - 隐式SSL端口990

时间:2016-09-07 10:16:46

标签: php ssl ftp implicit

我创建了一种方法,允许用户将数据库导出为CSV,然后将其上传到外部FTP服务器。

我在我的本地机器上进行了测试,一切似乎都很好。

然而,一旦我将代码推送到prod环境,连接似乎就会超时。我确实增加了服务器上的超时,但似乎没有帮助。

我收到以下错误

There was an error in uploading the file :::: Failed to connect to xxx.xxx.xxx port 990: Connection timed out

代码

if ($fp = fopen($local, 'r')) {
        $ftp_server = 'ftps://' . $this->server . '/' . $remote;
        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $ftp_server);
        curl_setopt($ch, CURLOPT_PORT, 990);
        curl_setopt($ch, CURLOPT_USERPWD, $this->username . ':' . $this->password);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_FTP_SSL, CURLFTPSSL_ALL);
        curl_setopt($ch, CURLOPT_FTPSSLAUTH, CURLFTPAUTH_TLS);
        curl_setopt($ch, CURLOPT_UPLOAD, true);
        curl_setopt($ch, CURLOPT_INFILE, $fp);

        $result = curl_exec($ch);
        $err = curl_error($ch);

        curl_close($ch);

        if ($err) {
            mail(ERROR_EMAIL, 'ERROR - Uploading file failed!.', date('F j, Y, g:i a e O')."] - There was an error in uploading the file :::: " . $err);
            error_log("[".date('F j, Y, g:i a e O')."] - There was an error in uploading the file :::: " . $err . "\n", 3, __DIR__."/errors.log");
        }
        error_log("[".date('F j, Y, g:i a e O')."] - File Successfully Uploaded.\n", 3, __DIR__."/errors.log");
        return !$err;
    }

这是在类中找到的函数的内容。想知道我是否遗漏了什么。

$remote -> this is the file path to the remote file. on the server. 

$local -> this is the file on the local server.

1 个答案:

答案 0 :(得分:0)

问题在于不允许使用端口990。这是托管提供商的问题,因此跟进了另一个解决方案。

感谢您的评论,为我节省了一些时间。