Mimic Gmail"s "Download as .zip" feature

Mimic Gmail"s "Download as .zip" feature

am 04.08.2007 09:11:39 von techusky

I'm in the process of making a custom directory listing script for my
website, and I want to learn how to mimic Gmail's feature that lets
you download all the attachments in an e-mail as a single .zip file.

I have lots of little folders which some of my users need to
frequently download the contents of, so I'm curious how this is done.

Does anyone have any suggestions to at least get me started in the
right direction?

Re: Mimic Gmail"s "Download as .zip" feature

am 04.08.2007 09:39:50 von Matt Madrid

techusky@gmail.com wrote:
> I'm in the process of making a custom directory listing script for my
> website, and I want to learn how to mimic Gmail's feature that lets
> you download all the attachments in an e-mail as a single .zip file.
>
> I have lots of little folders which some of my users need to
> frequently download the contents of, so I'm curious how this is done.
>
> Does anyone have any suggestions to at least get me started in the
> right direction?
>

You could use the Zip file functions if your PHP installation was
compiled with zip support: http://www.php.net/manual/en/ref.zip.php
or use the exec() command to zip the files using the zip binary on
your system and present the zip file for download.

On-the-fly, you could send them to a script that does this.

Your link:




Your code (zipem.php):

<>

header("Content-type: application/zip");
print file_get_contents($zip_filename);


Or, instead of reading the entire (possibly large) file into memory,
you could redirect them to the URL of where the newly created zip
file is, assuming that it is located within the DocumentRoot of
the server.

<>

header("Location: /path/to/zip/file.zip");


Hope this helps..

Matt M.