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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥20 java项目连接sqlserver时报ssl相关错误
    • ¥15 一道python难题3
    • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler
    • ¥15 oracle集群安装出bug
    • ¥15 关于#python#的问题:自动化测试