Forum Moderators: coopster

Message Too Old, No Replies

Creating ZIP files on the fly using PHP and gzip

Anyone know how to do this?

         

rycrostud

3:10 pm on Jan 20, 2003 (gmt 0)

10+ Year Member



Hi,

I'm looking into ways of creating ZIP files on my server using gzip. There seems to be lots of information on streaming and compressing web pages before they're served to the browser but not much on how to simply take file "a.html" and create a compressed one "a.gz".

It's for a file sharing utility. Once users have uploaded a file I want the server to automatically compress it to save space.

Any hints or good tutorials greatly appreciated.

hakre

4:57 pm on Jan 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi rycrostud,

just use gzip -h to get the help of gzip. you can use shellexec in php to start gzip in your website. for your taks this might suit:

gzip -c file >file.zip
(this won't delete file)

or
gzip -S .zip file
(this will delete the input file)

hope this helps.

rycrostud

5:04 pm on Jan 20, 2003 (gmt 0)

10+ Year Member



Hi hakre,

Thanks for the tips. After a bit of searching I've found a very easy to use class on the Zend [zend.com] web site.

It works perfectly and with a bit of modification it will do exactly what I require.