[eluser]louis w[/eluser]
After testing this out, I didn't like how the data inside the folder I was trying to add still needed to be inside a directory in the archive. I checked out the CI read_dir call, a couple small changes you can call read_dir to create an archive containing all the files without any directories. Even works with nested folders.
Code:
class MY_Zip extends CI_Zip {
function read_dir($path, $base=null) {
if (is_null($base)) $base = $path;
if ($fp = @opendir($path)) {
while (FALSE !== ($file = readdir($fp))) {
if (@is_dir($path.$file) && substr($file, 0, 1) != '.') {
$this->read_dir($path.$file."/", $base);
} else if (substr($file, 0, 1) != ".") {
if (FALSE !== ($data = file_get_contents($path.$file))) {
$file_name = ltrim($path.$file, $base);
$this->add_data($file_name, $data);
}
}
}
return TRUE;
}
}
}