Forum Moderators: coopster

Message Too Old, No Replies

zip files, then force download

         

digitsix

11:02 am on Feb 25, 2004 (gmt 0)

10+ Year Member



Is there any examples or scripts that already will do this?

I need to zip an arbitrary amount of files, say maybe a $files array full of path names to the files filled dynamically from database based on an id number...

then i need it to automatically force a download of the zip file to the browser, then automatically delete the zip file when its finished...

I know there has to be a way to do this... any examples or insight?

Thanks,
Rick

coopster

12:52 pm on Feb 25, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You could use the Zlib Compression Functions [php.net] and once you've created the zipped file use the PHP header() [php.net] function to send it on its way.

Birdman

2:10 pm on Feb 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



And then use unlink("file.zip") [php.net] to delete the file.

coopster

3:45 pm on Feb 25, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Thanks Birdman, I missed that step.

And hey, digitsix, welcome to WebmasterWorld!

digitsix

8:29 pm on Feb 25, 2004 (gmt 0)

10+ Year Member



i figured i could do it that way, its just that i wasnt sure if i used the unlink() at the end of the script it would kill the file before the user finished downloading it... i guess ill just have to try and find out the hard way ;)

thanks for the input!