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



techusky@xxxxxxxxx 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.
.



Relevant Pages

  • Re: Opening up in RichTextBox2 ?
    ... sample is for a quick way to build a really big string from other string ... reading option. ... I'm quietly confident that the website I ... A 24 hour download ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Not compatible with Firefox and other browsers - WHY?
    ... etc and the formatting of my website and functionality ... You should download and install FireFox so you can test your pages before ... Open your publication in Publisher and select the text ... note that the first javascript code snippet is incorrect on the website. ...
    (microsoft.public.publisher.webdesign)
  • Re: Opening up in RichTextBox2 ?
    ... I'm quietly confident that the website I ... a certain location or if the download gets interrupted somehow. ... and a permanent place to store its logs. ... on my C:/ drive I currently have a folder ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Opening up in RichTextBox2 ?
    ... Sounds like you've given a lot of thought to the WebBrowser control ... I'm quietly confident that the website I ... a certain location or if the download gets interrupted somehow. ... and a permanent place to store its logs. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: I am put off from joining this group because of all the spam
    ... time than a single quick visit to a website. ... were interested in to download the bodies later. ... GUI for the news feed. ... indeed I still have my newsreader set to ...
    (uk.rec.walking)