setSendHttpHeaders(true); // create a new zipstream object $zip = new ZipStream\ZipStream('example2.zip', $options); // create a file named 'hello.txt' $zip->addFile('hello.txt', 'This is the contents of hello.txt'); // add a file named 'goodbye.txt' from an open stream resource $fp = tmpfile(); fwrite($fp, 'The quick brown fox jumped over the lazy dog.'); rewind($fp); $zip->addFileFromStream('goodbye.txt', $fp); fclose($fp); // finish the zip stream $zip->finish(); //EXIT LINE IS VERRY IMPORTANT-------------will send html if missing exit; ?>