dsjk3214 2016-02-02 07:12
浏览 36

Codeigniter使用现有文件夹创建zip文件并下载。

I am trying to create zip with existing folder. That folder having sub folders and files.
I am using codeigniter 2.1.4. For this i tried as below:

$this->load->library('zip');
$this->zip->read_dir($_SERVER['DOCUMENT_ROOT'].'/cloudsip_v2/apps/feb012016/'); ob_end_clean(); $this->zip->download('feb012016.zip');


But its downloading empty zip file.

  • 写回答

2条回答 默认 最新

  • duanlaofu4108 2016-02-02 07:35
    关注

    try this ::

    $name = 'mydata1.txt';
    $data = 'A Data String!';
    
    $this->zip->add_data($name, $data);
    
    // Write the zip file to a folder on your server. Name it "my_backup.zip"
    $this->zip->archive('/path/to/directory/my_backup.zip');
    
    // Download the file to your desktop. Name it "my_backup.zip"
    $this->zip->download('my_backup.zip'); 
    

    here is link

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?