2014-03-25 33 views
0

所以我想用笨FTP類,和我試圖運行下面的代碼不工作:笨FTP類沒有錯誤,如預期

public function ftp() 
{ 
    echo 'test1'; 
    $config['hostname'] = $this->config->item('ftp_hostname'); 
    $config['username'] = $this->config->item('ftp_username'); 
    $config['password'] = $this->config->item('ftp_password'); 
    $config['debug'] = $this->config->item('ftp_debug'); 

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

    $list = $this->ftp->list_files('/'); 

    print_r($list); 

    $this->ftp->close(); 

    echo 'test2';  
} 

當我訪問的頁面我只得到消息'test1',它不會在頁面上列出任何內容。起初,我認爲這是我的家庭服務器的問題,但是當檢查phpinfo()時,它表明ftp是一個可接受的協議,所以它肯定不是服務器問題?無論如何,任何幫助表示讚賞。

很多謝謝。

回答

0

您是否加載了le library FTP?

$this->load->library('ftp'); 

如果您已經加載庫,請嘗試將登錄信息寫入測試函數中。

$config['hostname'] = 'localhost'; 
$config['username'] = 'LoginFTP'; 
$config['password'] = 'passFTP'; 
$config['port']  = 21; 
$config['passive'] = FALSE; 
$config['debug'] = TRUE; 

我希望它能幫助你。