note 30630 added to function.gzcompress

From: Date: Mon, 24 Mar 2003 13:45:06 +0000
Subject: note 30630 added to function.gzcompress
Groups: php.notes 
Request: Send a blank email to php-notes+get-45734@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/function.gzcompress.php http://master.php.net/manage/user-notes.php?action=edit+30630 http://master.php.net/manage/user-notes.php?action=delete+30630 http://master.php.net/manage/user-notes.php?action=reject+30630

« previous php.notes (#45734) next »