dongzhimeng2464 2015-06-24 06:14
浏览 412

使用ftp_connect连接但无法登录PHP

I am creating an application which connects to FTP(with secured connection). This Might be stupid question but I really need help. My query is-

I am creating application to connect to FTP server which is secured(FTP-SSL / FTP Secure). I have used two approaches

  1. ftp_connect()
  2. ftp_ssl_connect()

Approach 1 - ftp_connect()

<?php
        $ftp_server = "ftp.xxx.xxx";
        $ftp_user_name = "xxx";
        $ftp_user_pass = "xxxxxx";

        $conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
        ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
?>

My problem is, connection is established but when I try to login it is throwing this error. When I remove ftp_login() I am not getting any error. I know this is because of ftps. That is why I used second approach.

Warning: ftp_login(): Sorry, cleartext sessions are not accepted on this server.

Approach 2 - ftp_ssl_connect()

<?php
        $ftp_host = 'ftp.xxx.xxx';
        $ftp_user = 'xxxxxx';
        $ftp_password = 'xxxxxx';

        var_dump(function_exists('ftp_ssl_connect'));

        if(function_exists('ftp_ssl_connect'))
        {
            $ftp_connection = @ftp_ssl_connect($this->ftp_host);
        }

        if($ftp_connection)
        {
            ftp_login($ftp_connection, $this->ftp_user, $this->ftp_password);
        }
    ?> 

I used this approach ftp_ssl_connect() to connect ftp (with secured connection server). But the statement is printing bool(False). This means ftp_ssl_connect() is not available to use.

What should I do to connect ftp (with secured connection) server?. I tried replacing ftps over ftp in URL. it is showing the same error.

Update - 1 application will be hosted at Linux server. I am developing and testing application on windows 7 machine.

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料