in reply to Examples of Archive::Zip

You just posted this (more or less) same question 2 days ago (I am assuming that you are the author of temporary file zipping). If you noted the example I provided, you have the answer to your question. The script I provided is the backbone of what you need. It creates a new in-memory zip file, sends it to the user for download and then exits, without saving the zip file anywhere.

Replies are listed 'Best First'.
Re: Re: Examples of Archive::Zip
by Anonymous Monk on Apr 06, 2004 at 14:07 UTC
    Thank you for YOUR reply! I tried using this and it kept erroring out. I ended up having to use CGI qw/:standard/ instead of Simple, but those little changes shouldn't be causing the problem.

    I uploaded foobar.txt in the same folder using an absolute path and at run time I get PK=8†0 foobar.txtadadasddsC™ PK=8†0C™ ¶foobar.txtPK8=. This proves two things though. It proves it can find the foobar.txt and is goofing around with it and also proves it can read it "adadasdds" is the entirety of the text file.

    I get this text message to browser, it doesn't die or anything and no popup window exists. What should I do?

    #!/usr/bin/perl use warnings; use CGI::Carp 'fatalsToBrowser'; $|++; use strict; use CGI qw/:standard/; use Archive::Zip; my $fileToUpload = 'foobar.txt'; my $zip = Archive::Zip->new(); open( my $fh, '<', $fileToUpload ) or die "open failed: $!"; binmode( $fh ); # for win32 my $contents = do { local $/; <$fh> }; close( $fh ); $zip->addString($contents, $fileToUpload); print header( -type => 'application/zip', -attachment => "$fileToUpload.zip" ); binmode( STDOUT ); # once again, for win32 $zip->writeToFileHandle(\*STDOUT);