powerhouse has asked for the wisdom of the Perl Monks concerning the following question:

I am just wondering if someone knows of a module that already exists where I can take images and create a zip file dynamically with those images?

I am making a package system where people can choose images they want to download and it will automatically add them to a zip file with a .txt file and give them a link to download it. I will have the system delete the file 24 hours AFTER they download it. I will use a Perl Script to download the zip file so I can track it being downloaded.

I would appreciate any wisdom in this regard...
thx,
Richard

Replies are listed 'Best First'.
Re: Creating a Zip file with Perl
by bgreenlee (Friar) on Aug 11, 2004 at 07:25 UTC
Re: Creating a Zip file with Perl
by rupesh (Hermit) on Aug 11, 2004 at 09:49 UTC

    Type in the folder name and the name of the zip file.
    #!c:\perl\bin\perl -w use strict; use IO::Handle; use Cwd; use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); my ($tree, $zipname); my $zip = Archive::Zip->new(); { my $today = scalar localtime(); if ( $#ARGV != 1 ) { print "$0:Usage $0 directory_tree zip_file_name\n"; exit; } else { $ARGV[0] =~ s/\"//g; $zip->addTree( "$ARGV[0]", '.' ); $zipname = $ARGV[1]; } $zipname =~ s/\"//g; $zipname.=".zip" if ($zipname !~ /\.zip$/); $zip->zipfileComment("Zipping up images.\n Date of Zip: $today"); + ($zip->writeToFileNamed("$zipname") eq 0) or die print "couldn\'t write to zip file. Reason: $!" +; }

    ...Tested in Windows