Jus*_*ell 0 php zip codeigniter
我使用标准CI zip库来读取目录并创建一个zip文件以供下载但是当我在Windows中测试时,我得到:

在OS X中,zip解压缩一个cpgz文件,然后无限制地解压缩到一个zip文件
我的CI功能:
public function downloadPackage($unique) {
$this->load->library('zip');
$text = $this->syndication_m->getTextForContent($unique);
$path = '/var/www/html/uploads/'.$unique.'/';
if(file_exists($path."copy-".$unique.".txt")) {
unlink($path."copy-".$unique.".txt");
$fp = fopen($path."copy-".$unique.".txt","wb");
fwrite($fp,$text);
fclose($fp);
}
$this->zip->read_dir($path);
$this->zip->download('dl-'.$unique.'.zip');
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我修复或建议在这做什么?谢谢
编辑
public function downloadPackage($unique) {
$this->load->library('zip');
$path = '/var/www/html/uploads/'.$unique.'/';
$text = $this->syndication_m->getTextForContent($unique);
$this->zip->read_dir($path, TRUE);
$this->zip->add_data('copy-'.$unique.'.txt', $text->synd_text);
$this->zip->download('dl-'.$unique.'.zip');
}
Run Code Online (Sandbox Code Playgroud)