1回のダウンロードで複数のファイルを結合する必要があるため、Webサイトからzipファイルをダウンロードする必要があります(最大100個の個別のファイル程度)。
zip ファイルを作成しようとすると、意図したとおりにダウンロードされ、ファイル名も意図したとおり「YYYY.MM.DD - HH.MM.SS」の形式で表示されます。この問題は、Windows 7 (または winzip)で zip ファイルを開こうとすると発生します。以下のエラー メッセージが表示されます。これは、複数の試行から繰り返し発生します。
別のzipファイルを開くことができるため、zipファイル形式自体が問題になるのではなく、zipファイルの作成またはダウンロードのコーディング中にエラーが発生したと思います-誰かが私がおそらく犯した間違いを見ることができますか? (エラー画像の下に含まれるコード)
PHPを参考にして、Download multiple filesをzipファイルとして使用しようとしました。
//backup file name based on current date and time
$filename = date("Y.m.j - H.i.s");
//name of zip file used when downloading
$zipname = 'temp.zip';
//create new zip file
$zip = new ZipArchive;
$zip->open($zipname, ZipArchive::CREATE);
//yes, I know the zip file is empty currently - I've cut the code from here for
//now as the zip file doesn't function with / without it currently
$zip->close();
//download file from temporary file on server as '$filename.zip'
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename='.$filename.'.zip');
header('Content-Length: ' . filesize($zipname));
readfile($zipname);