dongmu1390 2015-01-20 20:14 采纳率: 100%
浏览 44
已采纳

CodeIgniter Zip库未加载

i'm trying to load the zip library, but for some reason i cant't, it show me this error:

A PHP Error was encountered

Severity: Notice

Message: Undefined property: CI::$zip

Fatal error: Call to a member function add_data() on a non-object in C:\xampp\htdocs\cinetaller\frontend-cin\controllers\usuario.php on line 72

This is the code from my controller:

    public function index(){

        $this->load->library('zip');
        $data = array();
        $data['www'] = $this->config->item('base_www');
        $data['alumno'] = $this->malumno->getById(1)->row();

        echo "start zip";

        $name = 'mydata1.txt';
        $dataZ = 'A Data String!';

        $this->zip->add_data($name, $dataZ);

        // Write the zip file to a folder on your server. Name it "my_backup.zip"
        $this->zip->archive($data['www'].'/uploads/'.$data['alumno']->id); 

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

        echo "done";
}

I'm shure, that the zip library is in the core system, but for a no reason i can't load it.

  • 写回答

1条回答 默认 最新

  • doujinai2183 2015-01-20 21:45
    关注

    try your test without the download command and see if it loads. i'm saying that because in the ci manual after

    $this->zip->download()
    

    it says: Note: Do not display any data in the controller in which you call this function since it sends various server headers that cause the download to happen and the file to be treated as binary. http://www.codeigniter.com/user_guide/libraries/zip.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?