You are here: Re: Mimic Gmail's "Download as .zip" feature « PHP Programming Language « IT news, forums, messages
Re: Mimic Gmail's "Download as .zip" feature

Posted by Matt Madrid on 08/04/07 07:39

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:

<a href="zipem.php">Download zipped</a>


Your code (zipem.php):

<<ZIP THE FILES>>

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.

<<ZIP THE FILES>>

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


Hope this helps..

Matt M.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация