this is what I need
$a=array('folder'=>'anyfolder','filename'=>'anyfilename','filedata'=>'anyfiledata');
I need to create a variable $zip with compressed data from $a and output this $zip into browser window with
header('Content-type: application/octetstream');
echo $zip;
All libs that I found, they pack files and create zip files physically on disk. I need to do it dynamically, using memory. Is there any examples of how to do it using pure php's zlib and without studying the zip format specifications?
UPD:
could it be done with CreateZIP class?
UPUPD:
Yes. it could =)
Yes, CreateZIP class does it.
require_once('CreateZipFile.php');
$zip = new CreateZipFile;
$zip->addFile('anyfiledata', 'anyfilename');
$zip->addFile('anyfiledata2', 'anyfolder/anyfilename.anyext');
$zip->addDirectory('anyemptydirwouldbecreatedinthiszipfile');
header('Content-disposition: attachment; filename='.'zipfile.zip'.'');
header('Content-type: application/octetstream');
echo $zip->getZippedfile();
die();
great thanx to Er. Rochak Chauhan
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With