[pmwiki-users] Create zip file

Patrick R. Michaud pmichaud at pobox.com
Tue Nov 13 12:39:48 CST 2007


On Tue, Nov 13, 2007 at 05:32:41PM +0100, Mike wrote:
> Hello,
> 
> I'm looking for a way to dynamically create a zip file for user download
>  which will be created when the user clicks the respective link and will
> contain all files in a given directory. Usage will be a picture gallery,
> the idea is to store all pictures on the disk only once and offer an
> additional download link without using any more space.
> 
> Would there be an easy way to achive this? Thanks,

If your PHP installation supports the system() function, then you
could easily use it for creating the zip file and returning it:

  <?
    header("Content-type: application/zip");
    system("/usr/bin/zip - gallery/*.jpg");

Here, the /usr/bin/zip command says to create a zip file of all
of the *.jpg files in the gallery/ directory, and send that zip
file to the output (i.e., the browser).

Unless you have special permissions issues that you want to handle,
it might be worthwhile to create this as a separate .php script
instead of adding it into PmWiki.  If you need it to participate
in PmWiki's access control mechanisms, then it makes more sense
as a recipe or local customization, and for that I would recommend
creating a custom  ?action=zipdownload or the like.

Pm




More information about the pmwiki-users mailing list