my $file = 'd:\imaging\building.jpg'; my $zip_name = get_session() . ".zip"; my $zip = Archive::Zip->new(); $zip->addFile($file) or die "Can't add to zip!\n"; $zip->writeToFileNamed($zip_name); my $filesize = -s $zip_name; my $buffer; # Read the zip file open READ, "< $zip_name" or die "Cannot open $zip_name for reading: $!"; binmode READ; { local $/; $buffer = ; } close(READ); binmode STDOUT; print "Content-Disposition: inline; filename=document.zip\n"; print "Content-Length: $filesize\n"; print "Content-Type: application/zip\n\n"; print $buffer;