Php codeigniter Zip编码类添加多个文件

Php codeigniter Zip编码类添加多个文件,php,codeigniter,loops,zip,Php,Codeigniter,Loops,Zip,我现在是这样做的: $path = "./uploads/1.txt"; $path1 = "./uploads/4.txt"; $this->zip->read_file($path); $this->zip->read_file($path1); $this->zip->download('files_backup.zip'); 现在我想从数据库查询中添加文件,该查询返回文件的路径 $data['query'] = $this->db->g

我现在是这样做的:

$path = "./uploads/1.txt";
$path1 =  "./uploads/4.txt";
$this->zip->read_file($path);
$this->zip->read_file($path1);
$this->zip->download('files_backup.zip');
现在我想从数据库查询中添加文件,该查询返回文件的路径

$data['query'] = $this->db->get_where('files', array('uid'=>$uid));
现在请告诉我调用
$this->zip->read\u文件($path)必须使用哪个循环

根据上述查询的结果

谢谢

编辑:

foreach ($query->result() as $row)
{
    echo $row->filename;
}
 <form method='post' action='<?= base_url() ?>index.php/zip/createzip/'>
            <input type="submit" name="but_createzip1" value='Add file from path and download zip'>
 </form>
结果

335476sfsr.txt 
egyafhwe7g.txt
4566weyt36.txt
public function createzip(){

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

      $query = $this->db->get('items');

      foreach ($query->result() as $row)
        {
          $fileName = FCPATH."./uploads/".$row->img;
          $this->zip->read_file($fileName);
        }

       $filename = "backup.zip";
       $this->zip->download($filename);
 }

因此,它只显示该用户的文件。

好的,然后像这样编辑给定的循环

foreach ($query->result() as $row)
{
    $this->zip->read_file($row->filename);
}

$this->zip->download('files_backup.zip');

创建一个带有表项的数据库并添加IMG列,然后使用此代码

查看:

foreach ($query->result() as $row)
{
    echo $row->filename;
}
 <form method='post' action='<?= base_url() ?>index.php/zip/createzip/'>
            <input type="submit" name="but_createzip1" value='Add file from path and download zip'>
 </form>

我们需要更多关于数据库模式的信息,您的查询是否返回多行?看起来uid将返回一行。我已经编辑了问题并添加了查询结果。非常感谢单文件下载,但出现多个文件错误!