note 30631 added to ref.zlib
| From: | devcontact at tech-island dot com | Date: | Mon, 24 Mar 2003 13:47:49 +0000 |
| Subject: | note 30631 added to ref.zlib | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-45735@lists.php.net to get a copy of this message | ||
The method of first reading the source file and then passing its content to the gzip function
instead of simply the source and destination filename was a bit confusing for me.
So I have written a simple funtion you can use to compress files in the gzip format (gzip is
readable by winzip like .zip files)
function compress($srcName, $dstName)
{
$fp = fopen($srcName, "r");
$data = fread ($fp, filesize($srcName));
fclose($fp);
$zp = gzopen($dstName, "w9");
gzwrite($zp, $data);
gzclose($zp);
}
// Compress a file
compress("/web/myfile.dat", "/web/myfile.gz");
--
http://www.php.net/manual/en/ref.zlib.php
http://master.php.net/manage/user-notes.php?action=edit+30631
http://master.php.net/manage/user-notes.php?action=delete+30631
http://master.php.net/manage/user-notes.php?action=reject+30631