I have a script for create zip with images. It works really well !
create_zip($files_to_zip, 'zip/download-'.$id_account.'-'.$time.'.zip');
function create_zip($files = array(),$destination = '',$overwrite = true) {
if(file_exists($destination) && !$overwrite) { return false; }
$valid_files = array();
if(is_array($files)) {
foreach($files as $file) {
if(file_exists($file)) {
$valid_files[] = $file;
}
}
}
if(count($valid_files)) {
$zip = new ZipArchive();
if($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {
return false;
}
foreach($valid_files as $file) {
$zip->addFile($file,$file);
}
$zip->close();
return file_exists($destination);
}
else { return false; }
}
When I download the file, it's well named zip/download-'.$id_account.'-'.$time.'.zip
But when I want to extract this, the extract folder is always named files
.
result
Please do you have any idea for rename my unzipped file to an another name ?
Thanks a lot !