ユーザーが必要な PDF パンフレットを選択できるフォームを作成しようとしています。ダウンロードできるように、ファイル名「Brochures.zip」として圧縮されます。
これを取得するのに問題があります。誰がどこが間違っていたかを強調できますか? ありがとう!
形 :
<label><input type="checkbox" name="brochure[]" value="file1">file1</label>
<label><input type="checkbox" name="brochure[]" value="file2">file2</label>
<label><input type="checkbox" name="brochure[]" value="file3">file3</label>
<label><input type="checkbox" name="brochure[]" value="file4">file4</label>
ダウンロード.php
$brochure = $_POST['brochure'] ;
$send = true;
if($send) {
$zip = new ZipArchive();
$res = $zip->open('download.zip', ZipArchive::CREATE);
if ($res === TRUE) {
foreach ($brochure as $file => $val) {
$filename = '../pdf/' . $val . '.pdf';
$zip->addFile($filename);
}
$zip->close();
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="download.zip"');
readfile('download.zip');
}else {
echo 'failed';
}