You've got mangled code, that's why. You're opening the file to the FILE handle, then binmoding and reading from MY_FILE, which, in this script, does not exist. As for sending an 'anonymous' file, follow the advice given by another monk below and just move the files out of the web server's document root.
use CGI; my $q = CGI->new(); my $buf_size = 4096; my $file_root = '/home/goldcal/files'; # not in /www! open( my $fh, '<', "$file_root/wlmlm401.exe" ) or die("open failed: $!"); binmode($fh); print $q->header( -type => 'application/exe', -expires => '-1d' ); binmode(STDOUT); my $buf; while ( read($fh, $buf, $buf_size) ) { print $buf; }
In reply to Re: Getting CGI script to send a binary file
by saskaqueer
in thread Getting CGI script to send a binary file
by jdtoronto
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |