What's the easiest way to zip, say 2 files, from a folder on the server and force download? Without saving the "zip" to the server.
$zip = new ZipArchive();
//the string "file1" is the name we're assigning the file in the archive
$zip->addFile(file_get_contents($filepath1), 'file1'); //file 1 that you want compressed
$zip->addFile(file_get_contents($filepath2), 'file2'); //file 2 that you want compressed
$zip->addFile(file_get_contents($filepath3), 'file3'); //file 3 that you want compressed
echo $zip->file(); //this sends the compressed archive to the output buffer instead of writing it to a file.
Can someone verify: I have a folder with test1.doc, test2.doc, and test3.doc
with the above example - file1 (file2 and file3) might just be test1.doc, etc.
do I have to do anything with "$filepath1"? Is that the folder directory that holds the 3 docs?
Sorry for my basic question..