Php Codeigniter Zip库

Php Codeigniter Zip库,php,codeigniter,zip,Php,Codeigniter,Zip,嗨,我只是想知道是否可以使用codeigniter Zip库在本地驱动器上创建一个Zip,然后向其中添加文件 下面是代码 $this->load->library('zip'); if (($handle = fopen($media_file, "r")) !== FALSE) { $row = 1; while (($data = fgetcsv($handle)) !== FALSE)

嗨,我只是想知道是否可以使用codeigniter Zip库在本地驱动器上创建一个Zip,然后向其中添加文件

下面是代码

$this->load->library('zip');
if (($handle = fopen($media_file, "r")) !== FALSE) 
        {
            $row = 1;

            while (($data = fgetcsv($handle)) !== FALSE) 
            {
                if($row > 1)
                {
                    $image_name = isset($data[1]) ? $data[1] : null;

                    if(!empty($image_name))
                    {
                        $this->zip->read_file("C:/files/Images/$image_name"); 
                    }   
                }

                $row++;
            }
        }
         $this->zip->download('Media.zip');
我想在本地驱动器上创建一个zip,并向其中添加文件,而不是下载zip

如果有人能帮我,我会非常感激。我尝试过使用PHPZIP,但由于一些奇怪的原因,它忽略了一些文件

示例-我的拉链

/**
 * Created by websky
 */
class myZipper extends ZipArchive{
    protected $dir;
    protected $archive;
    protected $pathsArray;

    /**
     * @param string $dir
     * @param string $name
     */
    public function __construct($dir,$name){
        $this->dir = $dir;
        $this->archive = $name;
        $this->open($this->archive, myZipper::CREATE);
        $this->myScanDir($this->dir);
        $this->addZip();
        $this->getZip();
    }

    /**
     * @param string $dir
     */
    protected function myScanDir($dir){
        $files = scandir($dir);
        unset($files[0], $files[1]);
        foreach ($files as $file) {
            if(is_dir($dir.'/'.$file)){
                $this->myScanDir($dir.'/'.$file);
            }
        else {
                $this->pathsArray[] = array('oldpath' => $dir.'/'.$file, 'newpath'=>  (($this->dir == $dir)? $file : str_replace($this->dir.'/', '', $dir).'/'.$file));
            }
        }
    }

    protected function addZip(){
        foreach($this->pathsArray as $path){
            $this->addFile($path['oldpath'],$path['newpath']);
        }
    }

    public function getZip(){
        $this->close();
        header('Content-Type: application/zip');
        header('Content-disposition: attachment; filename='.$this->archive);
        header('Content-Length: '.filesize($this->archive));
        readfile($this->archive);
        unlink($this->archive);
    }
    }

    $test = new myZipper('C:/files/Images', 'Images.zip');
myZipper(源文件、存档名称)