exec("pkzip -a packedfile.zip file1.txt file2.txt");
Which requires the pkzip to be in PATH..
Writing the whole thing takes too long. But a tip is to
name the checkboxes <input type="checkbox" name="FILE:myfile.txt"> then when submitting (loading the file that sends the file) use:
<?php // file is i.e sendfile.php
$zipfile = "files.zip"; // the name of the zip we create.
while (list($var, $value) = each($HTTP_POST_VARS)) {
if(substr($var,0,5)=="FILE:") { // is it our checkboxes?
$tmparr = explode(":",$var); // split at :
$filename = $tmparr[1]; //filename shouldbe "myfile.txt"
$filestoadd .= $filename." ";
}
}
exec("pkzip -a $zipfile $filestoadd");
header("Content-type: application/download");
header("Content-Length: ".filesize($zipfile));
header("Content-Disposition: inline; filename=$zipfile");
header("Content-Transfer-Encoding: binary");
readfile($filename); // Send it
?>
Good luck.