2
我有一個非常奇怪的問題,當壓縮一個目錄,並嘗試使用codeigniter下載。Codeignter Zip目錄和下載
下面是代碼
$this->load->library('zip'); //Loading the zip library
$directory = $_SESSION['directory-download-path']; //Getting the directory from session
$name = basename($directory); //get the name of the folder
$name = str_replace(" ", "_", $name).".zip"; //create the zip name
unset($_SESSION['directory-download-path']); //removing it from session
$this->zip->read_dir($directory); //read the directory
$this->zip->download($name); //download the zip
這是非常簡單的。下載發生問題。我得到的zip文件,但當我解壓縮它,我得到一個與.zip.cpgz文件,並繼續提取類似的文件。因此我認爲它已經損壞。你能幫我解釋爲什麼會發生這種情況。我有權限和目錄上的所有內容,因爲我正在執行其他操作。
編輯:
我經過一番更多的研究發現,添加第二個參數如下:
$this->zip->read_dir($directory, false); //read the directory
但仍然沒有工作。 另一種解決方案只是行前加
ob_end_clean();
:$this->zip->download($name); //download the zip
,但仍然沒有成功!
由於