2013-05-22 43 views
0

在我的網站中,我有以下2個功能。第一個使用FTP連接並在指定的路徑中創建一個目錄。例如,server.com/Host_path/DirectoryName。這段代碼工作得很好。我有一個上傳功能,將文件test.txt上傳到DirectoryName文件夾,第二個功能是將該文件下載到本地Windows機器上。但是,我收到錯誤消息Unable to download the specified file. Please check your path.沒有指出哪個路徑是錯誤的。CodeIgniter通過FTP將文件下載到窗口

$path = 'server.com/' . $result['path']; 
$this->ftp->mkdir($path); 

當我呼應遠程和本地路徑我得到remote = server.com/Host_path/DirectoryName/test.txt and local = C:\Users\Owner\Desktop\test.txt。基於這樣的事實,上述功能的工作原理,但下面的功能不,我相信Windows路徑是錯誤的,但它可能是在功能的差異。

$remotePath = 'server.com/' . $result['path']; 
$localPath = 'C:\\Users\\Owner\\Desktop\\test.txt'; 
$this->ftp->download($localPath, $remotePath, 'auto');` 

請幫忙!

+0

http://stackoverflow.com/questions/12331563/forcing-file-to-download-in-codeigniter-ftp-class – theB3RV

回答

0

對於remotePath,使用絕對路徑以 「/」

+0

沒有工作。我使用的是CodeIgniter,因此應該有一些方法可以使用base_url()或其他方法來完成。 – theB3RV