zentara has asked for the wisdom of the Perl Monks concerning the following question:
#############################################!/usr/bin/perl use warnings; use strict; my $boundary_string = "\n" . "--End" . "\n"; my $end_of_data = "\n" . "--End--" . "\n"; my @file_list = ("test.tgz","test1.tgz","test2.tgz"); print<<EOH; Content-type: multipart/x-mixed-replace\;boundary=End EOH foreach my $file (@file_list){ &amp;send_file ($file); print $boundary_string; } print $end_of_data; exit(0); sub send_file { my $file = $_[0]; if (open (FILE, "< $file")) { print<<EOF; Content-type: application/octet-stream Content-Disposition: attachment\; filename=$file EOF binmode FILE; print <FILE>; close (FILE); }else{print "Cannot open file $file!"} }
#########################################!/usr/bin/perl use CGI qw(:push); @ARGV = ("test.tgz","test1.tgz","test2.tgz"); $/ = undef; print multipart_init(); while (<>) { print multipart_start("application/octet-stream"); print $_; print multipart_end(); } print multipart_final();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI.pm woes with multipart attachments
by sedhed (Scribe) on Jul 25, 2002 at 21:53 UTC |