codeigniter中的ftp连接问题

问题描述 投票:0回答:1
       $this->load->library('ftp');

        $config['hostname'] = '127.0.0.1';
        $config['username'] = 'username';
        $config['password'] = 'password';
        $config['passive']  = FALSE;
        $config['debug']    = FALSE;
        $config['port'] = 21;

        $this->ftp->connect($config);

        $destination = '/assets/'.$file_name;

        //Upload file to the remote server
        $this->ftp->upload($source, ".".$destination, 'ascii', 0775);

        //Close FTP connection
        $this->ftp->close();

使用上述配置,并在本地Windows PC上安装filezilla FTP服务器。

if (FALSE === ($this->conn_id = @ftp_connect($this->hostname, $this->port))){
    if ($this->debug === TRUE){
            $this->_error('ftp_unable_to_connect');
    }
 return FALSE;}

程序在第一个条件中停止,$ this-> conn_id给出null值。没有给出任何错误。我怎么能连接到服务器?是否有任何添加配置要做。

谢谢

php codeigniter ftp filezilla
1个回答
0
投票

由于@开头的ftp_connect,你可能没有错误。根据文件(http://php.net/manual/en/language.operators.errorcontrol.php):

PHP支持一个错误控制操作符:at符号(@)。当在PHP中添加表达式时,将忽略该表达式可能生成的任何错误消息。

尝试不使用点,然后检查是否出现任何错误。

© www.soinside.com 2019 - 2024. All rights reserved.