wapped has asked for the wisdom of the Perl Monks concerning the following question:
When I run this I get a zip file with no contents. If I replace $id with "zipthis.txt" (the file on the server) everything works. I can't find an example of a program like this so I come the the mighty perl monks to answer my question and record an answer for others that may have this problem. Also, how would I make the perl file redirect to the zip file so it will download after the zip file is created? This will replace the else statement above. I tried#!/usr/bin/perl -w #use strict; use Archive::Zip qw(:ERROR_CODES :CONSTANTS); use CGI qw(:standard); if (param('link')){ my $id = param("link"); my $obj = Archive::Zip->new(); my $file_member = $obj->addFile( $id ); if ($obj->writeToFileNamed('download.zip') != AZ_OK) { print header; print "Bad something or other!"; } else { print header; print "<a href='download.zip'>archive created click to download</ +a>"; } }
but I get a whole bunch of text instead of the option to save or open. Thank You.#my $query=new CGI; #print $query->redirect('http://domain.com/files/download.zip');
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Archive::Zip with cgi empty zip file
by CSJewell (Beadle) on Mar 30, 2009 at 04:21 UTC | |
by wapped (Initiate) on Mar 30, 2009 at 05:26 UTC |