With the file in the cgi-bin directory I click on the link to the script and I get a blank browser page with no 'save as' dialogue.my $boundary_string = "\n" . "--End" . "\n"; my $end_of_data = "\n" . "--End--" . "\n"; my @file_list = ("wlmlm401.exe"); print <<EOH; Content-type: multipart/x-mixed\;boundary=End EOH foreach my $file ( @file_list ) { &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!"} }
So I tried merlyn's suggestion:
Which is as singularly unsuccesful.$/ = undef; @ARGV = ("/home/goldcal/www/files/wlmlm401.exe"); print multipart_init(); while(<>) { print multipart_start("application/octet-stream"); print $_; print multipart_end(); } print multiplart_final(); ## UPDATE - THis part should not have been here, it is finger trouble +;) #print $cgi->header( -type => "application/octet-stream", # -expires => "-1d", # -attachment => "wlmlm401.exe", # );
I am using Firefox 1.0 as my browser, but I did try it in IE and it works equally unwell.
In reply to Re: Getting CGI script to send a binary file
by jdtoronto
in thread Getting CGI script to send a binary file
by jdtoronto
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |