2012-07-19 34 views
1

我需要從我的本地主機上通過我的codeigniter應用程序上傳一個zip到我的網絡服務器。 我都跟着文檔,但我不能上傳文件,錯誤的是:Codeigniter FTP類

An Error Was Encountered 

Unable to locate the source file. Please check your path. 

我不能想通了,爲什麼它不能找到源路徑,如果我嘗試測試與file_exists路徑它的工作,但與upload方法失敗...

這是我的代碼:

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

$config_ftp['hostname'] = 'xxxxx'; 
$config_ftp['username'] = 'xxxxx'; 
$config_ftp['password'] = 'xxxxx'; 
$config_ftp['debug'] = TRUE; 

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

if(file_exists($my_file)) 
    echo "ok"; 
else 
    echo "no"; 

$this->ftp->upload($my_file , '/web/'.$my_file, 'binary'); 
+0

如果您使用'FCPATH'常量,這將爲您提供包含引導'index.php'的路徑。從那裏,你可以建立你想要上傳的文件的路徑。 – Gavin 2012-07-19 08:39:58

+0

你可以顯示'$ my_file'的內容嗎?如果你還沒有這樣做,請嘗試使用絕對路徑。 – Robert 2012-07-19 08:45:37

+0

使用'FCPATH',我從localhost:'/ Applications/MAMP/htdocs/AllWorks/Giovanetti2012/gestionale /'得到路徑,在這裏我追加了'$ my_file',它包含'gestionale'文件夾的路徑到zip文件,新路徑是:'/ Applications/MAMP/htdocs/AllWork/Giovanetti2012/gestionale/files/xml/auto/archive.zip',但它不起作用 – 2012-07-19 08:51:13

回答

0

我已經使用了標準的PHP函數用於FTP和現在的作品