Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用codeigniter删除zip文件_Codeigniter - Fatal编程技术网

使用codeigniter删除zip文件

使用codeigniter删除zip文件,codeigniter,Codeigniter,我想用codeigniter删除一个zip文件 这是我的控制器文件: public function delete($id) { $this->db->select('*'); $this->db->from('ag_angel1'); $this->db->where('angel1_id',$id); $this->db->join('ag_file','ag_file.f

我想用codeigniter删除一个zip文件

这是我的控制器文件:

public function delete($id)
    {
        $this->db->select('*');
        $this->db->from('ag_angel1');
        $this->db->where('angel1_id',$id);
        $this->db->join('ag_file','ag_file.file_id = ag_angel1.angel1_id','left');
        $ag=$this->db->get()->result();
        foreach($ag as $g){

            $path=realpath('uploaded/angel1/'.$g->file_name);

              if (file_exists($path)) {
              $this->load->helper('file');
                delete_files($path) or die('failed deleting: ' . $path);
              }else{
              $this->load->helper('file');
              unlike($path);
              }

        }
模型中的代码:

function delete($id)
    {
        if(!$id==null){

            $this->db->where('angel1_id',$id);
            if($this->db->delete('ag_angel1'))
            {
                return true;
            }

        }
    }
但它不起作用。
有什么问题吗?

$this->db->delete用于从数据库中删除数据要删除文件,请使用unlink

<?php unlink(server_path_to_your_file);?>
function delete($id)
    {
        if(!$id==null){

        $this->db->where('angel1_id',$id);
        if(unlink('path_to_your_file'))
        {
            return true;
        }

    }
}