in reply to Re: Archive::Zip with cgi empty zip file
in thread Archive::Zip with cgi empty zip file

Thanks, I renamed the file to nph-zipdownloader.cgi, Added :nph and redirect to the use CGI statement and consolidated the if statement with the assignment to the variable as well as adding the print redirect stuff and everything works. The zip file even has the text file in it. Link to the code http://domain.com/nph-zipdownloader.cgi?link=test.txt Here's the final code.
#!/usr/bin/perl -w use Archive::Zip qw(:ERROR_CODES :CONSTANTS); use CGI qw(:standard :nph redirect); if (my $id = param('link')){ $obj = Archive::Zip->new(); my $file_member = $obj->addFile( $id ); if ($obj->writeToFileNamed('download2.zip') != AZ_OK) { print header(type => 'text/plain'); print "Error in archive creation!"; #error checking } else { print redirect('http://domain.com/files/download2.zip'); } }
This is great, there's so much more I'm going to do with this code now that its making the zip file with content.