多个图像文件如何在Codeigniter中压缩

时间:2019-04-23 18:55:46

标签: php codeigniter

我的文件夹中有多张图片,并且在href按钮上得到了它。那么如何在codeigniter中压缩该文件。

这是我的查看代码:

composer.json

这是我的控制器:

<a href="<?php echo base_url()."index.php/itr1/download/".$key['pan_card']."/".$key['previous_itr'] ?>" name="images">Downalod All Attachments</a>

1 个答案:

答案 0 :(得分:0)

使用CI,其非常简单的CI具有zip库,您可以使用它来压缩数据,文件或文件夹并下载它们,这是创建zip和下载的方式

$id =  $this->uri->segment(3); 
$id1 =  $this->uri->segment(4); 

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

$filepath[] = FCPATH.'upload/'.$id;
$filepath[] = FCPATH.'upload/'.$id1;

foreach($filepaht as $file) {
  $this->zip->read_file($file);
}

// Download the file to your desktop. Name it "my_backup.zip"
$this->zip->download('my_backup.zip');

在此处详细了解zip库

https://www.codeigniter.com/user_guide/libraries/zip.html

相关问题