Re: gzip image files

From: Date: Tue, 27 Nov 2001 15:06:20 +0000
Subject: Re: gzip image files
References: 1 2 3  Groups: php.db 
Request: Send a blank email to php-db+get-14595@lists.php.net to get a copy of this message
and if i use $filename = 'kunden/'.$name.'.png'; $data = fopen($filename, "r"); $contents = fread($data, filesize($filename)); fclose($data); $gzdata = gzencode($data); $fp = fopen('kunden/zip/'.$name.'.gz', "w"); fwrite($fp, $gzdata); fclose($fp); it writes in the gz file this Resource id #3 > Yes, it is. > the return value of fopen is a resource of type file. > var_dump($data); will show that > if you want to read the data use : fread($data,$buf); > > but I think its better with file() function. The example from the docs show a better method: > <?php > $data = implode("", "bigfile.txt"); > $gzdata = gzencode($data, 9); > $fp = fopen("bigfile.txt.gz", "w"); > fwrite($fp, $gzdata); > fclose($fp); > ?> > > Regards, > Andrey Hristov > IcyGEN Corporation > http://www.icygen.com > BALANCED SOLUTIONS > > > ----- Original Message ----- > From: "Keith Whyman" <k.whyman@bf-72.de> > To: <php-db@lists.php.net> > Sent: Tuesday, November 27, 2001 4:23 PM > Subject: [PHP-DB] gzip image files > > > > I create a png dynamically - store the path in mysql. > > > > And want to be able to offer the user a zipped version to download > > Unfortunately haven't been able to get it to work up until now ! > > I'm sure it's something obvious but........... > > > > > > Open the png > > $data = fopen('kunden/'.$name.'.png', "rb"); > > encode it > > $gzdata = gzencode($data); > > where to write > > $fp = fopen('kunden/zip/'.$name.'.gz', "w"); > > write it > > fwrite($fp, $gzdata); > > fclose($fp); > > > > what happens is the name gets included in the gz but written to it is only > > kunden/example.png > > > > Can anyone help ?? > > > > thanks in advance > > regards > > keith > > > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > > For additional commands, e-mail: php-db-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.db (#14595) next »