I can't seem to get anything working from what I am finding when I try to search for a solution with what I need to do.
I am trying to create a form where a user will select 1 or more (bulk select all also) pdf files listed on a webpage.
When the user click submit, I want to have my PHP download file Create a zip file, Add the selected pdf files (store on the server) to the zip file and then force download the zip file to the end user.
When the user opens the zip file, the pdf files they selected from the webpage form are there for their use.
Everything I find either does not work, is not secure or has something to do with uploading the files first which I don't want to do. The files are already stored on my server.
Any help will be much appreciated.
<code>
$files = array($_POST['file']);
$zip = new ZipArchive();
$filename = "practiceforms";
$zip->open($filename, ZipArchive::CREATE);
foreach ($_POST['file'] as $key => $val) {
echo $path = "/images/docs/solutions/".$val.".pdf";
if(file_exists($path)){
$zip->addFile(basename($path), file_get_contents($path));
//$zip->addFromString(basename($path), file_get_contents($path));
}
else{
echo"file does not exist";
}
}
$zip->close();
echo header('Content-Length: ' . filesize($filename));
exit;
</code>