The simpler media website CMS
if (zip_entry_open($zip, $zip_entry, "r")) {
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
$path_file = str_replace("/",DIRECTORY_SEPARATOR, $dir . '/' . zip_entry_name($zip_entry));
$fp = fopen($path_file, "w");
fwrite($fp, $buf);
fclose($fp);
zip_entry_close($zip_entry);
}
}
zip_close($zip);
}
}
`
With:
`
function unzip($file, $dir)
{ //check if zziplib is installed
if(function_exists('zip_open()'))
{
$zip = zip_open($file);
if ($zip) {
while ($zip_entry = zip_read($zip)) {
// Skip non-images in the zip file.
if (!is_image(zip_entry_name($zip_entry))) continue;
if (zip_entry_open($zip, $zip_entry, "r")) {
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
$path_file = str_replace("/",DIRECTORY_SEPARATOR, $dir . '/' . zip_entry_name($zip_entry));
$fp = fopen($path_file, "w");
fwrite($fp, $buf);
fclose($fp);
zip_entry_close($zip_entry);
}
}
zip_close($zip);
}
}else{
// Use Zlib
require_once('pclzip.lib.php');
$zip = new PclZip($file);
if ($zip->extract(PCLZIP_OPT_PATH, $dir, PCLZIP_OPT_REMOVE_ALL_PATH) == 0) {
die("Error : ".$zip->errorInfo(true));
}
}
}
`
I think this should be included in the next releace.
A real feature request is a function to zip your images for batch download maby.
Alex
Comments
Great! This code snippet works wonders... I think it should be integrated into the standard product.
Side note, you might need to copy the entire revised function, instead of the highlighted parts shown above.
Thanks,
Damian