tags:

views:

43

answers:

1

Im looking to create a form where the user will select from a list of brochures. 10 in total.

They may only want to download 3 brochures, or 6, or 1, or 9, but the idea being they select what brochures they want and then a script combiles a zip file containg the required brochures.

Can anyone suggest anything?

+1  A: 

PHP has a Zip extension for this UseCase

Example from the manual page for ZipArchive::addFile

$zip = new ZipArchive;
if ($zip->open('test.zip') === TRUE) {
    $zip->addFile('/path/to/index.txt', 'newname.txt');
    $zip->close();
    echo 'ok';
} else {
    echo 'failed';
}

So, all you have to do is add the files the user selected to the ZipArchive and then send the Archive via header():

header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="test.zip"');
readfile('test.zip');
Gordon