2
イメージを持つzipを作成するためのスクリプトがあります。それは本当にうまくいく!PHPで作成したzipファイルの名前を変更します
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; }
}
私は、ファイルをダウンロードすると、それがよくzip/download-'.$id_account.'-'.$time.'.zip
という名前だが、私はこれを抽出する際に、抽出フォルダは常にfiles
という名前です。 result
解凍したファイルの名前を別の名前に変更してください。
ありがとうございます!