Sunday 15 May 2011

php - create zip file in codeigniter -



php - create zip file in codeigniter -

i want create zip file using codeigniter here code

$this->zip->read_dir($path, false); $this->zip->archive($path . '.zip');

code creating zip file properly. when extract zip, files within folder.

here folder structure

config /abc.xml /index.html /images /logo.png /data

when seek compress config folder, while extracting new config folder created. there way compress files , folder within config folder?

you could, reading directory , after invoking $this->zip->read_file() on each separate file. along these lines (not tested):

$files = array(); if ($handle = opendir($path)) { /* right way loop on directory. */ while (false !== ($entry = readdir($handle))) { if (!is_dir($entry)) { $files[] = $entry; } } closedir($handle); } foreach($files $file) { $this->zip->read_file($file); }

php codeigniter

No comments:

Post a Comment