Hey im am trying to compress multiple files using zlib but im not having any luck. I can compress single files but i cant find out how to create a table of contents for the .GZ file.
I read that the files need to be read into an array than imploded by then " character then written to the file. It didnt work?
Here is my code
PHP Code:<?
$files = array(
"test.jpg",
"test.png",
"test.php"
);
foreach($files as $file){
$temp = null;
$fp_in = fopen($file,'rb');
print "--opening "$file" for reading<br>";
while(!feof($fp_in)){
$temp .= fread($fp_in,1024);
}
$output[$file] = $temp;
fclose($fp_in);
print "--closing "$file"<br>";
}
$output = implode('"',$output);
$fp = gzopen("output.gz","wb");
print "opening "output.gz"<br>";
gzputs($fp,$ouput);
gzclose($fp);
print "closing "output.gz"";
?>


Reply With Quote

