Question : Downloading multiple zipped files

I'm trying to learn how to zip and download files. I found a solution on EE but can't get it to work. I am getting an Internal Server Error.

The tif files are in ../public_html/files.

I am new to perl/cgi so any assistance would be most appreciated.
I also searched for a self-extracting zip example on cpan but couldn't figure out how to view examples (i.e., examples/selfex.pl).

Thanks
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
#!/usr/bin/perl -wT
BEGIN {
open (STDERR, ">../public_html/error.txt");
}
use CGI ':standard';
use CGI::Carp qw(fatalsToBrowser);  
 
use Archive::Zip qw( :ERROR_CODES :CONSTANTS ) || die "Can't find Module";
my $zip = Archive::Zip->new();
my $q = new CGI;
 
my $i;
 
my $file1 = "p1.tif";
my $file2 = "p2.tif";
my $zip_file_name="MyFiles.zip";
 
#chdir into appropriate directory
chdir ('../public_html/files/');
 
 $zip->addFile("$file1");
 $zip->addFile("$file2");
           
die 'Cannot create $zip_file_name: $!\n' if $zip->writeToFileNamed("$zip_file_name") != AZ_OK;
 
#start downloading
$path = '../public_html/files/';
$filepath = "$path$zip_file_name";
my $size= -s $filepath;
my $buff;
 
print "Content-type: application/forced-download\r\n";
print "Content-Length: $size\r\n";
print "Content-disposition: attachment;filename=$zip_file_name\r\n\r\n";
open(FILE, "<$filepath") || die;
binmode FILE;
binmode STDOUT;
while (read FILE, $buff, 1024) {
 print $buff;
}
close(FILE);
Open in New Window Select All

Answer : Downloading multiple zipped files

Do you have access to any of these on the server (not perl modules, binaries): gzip, zip, or tar?

Random Solutions  
 
programming4us programming4us