2013-07-15 63 views
0

我想压缩一个文件夹(client1),其中包含几个pdf文件,然后zip文件夹应该下载。 路径正确但未能创建zip文件。read_dir()函数在codeigniter中不起作用

任何帮助将是appreciated.Thanks在提前

我做了下面的代码:

function download_all_pdf(){ 
$this->load->library('Zip'); 
$path = base_url().'public/pdfstore/client1'; 
$this->zip->read_dir($path); 
    $this->zip->download('client1.zip'); 
} 
+0

您路径不应是绝对路径,它应该是相对路径,在这里---> http://ellislab.com/codeigniter/user-guide/helpers/file_helper参考的文档。 HTML –

回答

0

不能使用http://路径。 Yu必须使用本地地址。因此,像这样

$path = 'public/pdfstore/clint1/' 
0

尝试:

function download_all_pdf(){ 
    $this->load->library('zip'); 
    $path = './public/pdfstore/client1'; 
    $this->zip->read_dir($path); 
    $this->zip->download('client1.zip'); 
} 
0

base_url()返回HTTP URL,但你需要一个本地路径。 一个不错的选择是使用便携式的本地路径。通过使用常数APPPATH来实现。如下图所示:

function download_my_zip_files(){ 
    $this->load->library('zip');    
    $basePath = APPPATH."/path/to/your/dir/"; 
    $this->zip->read_dir($basePath); 
    $this->zip->download('my_zip_file.zip'); 
}