Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Getting CGI script to send a binary file

by saskaqueer (Friar)
on Feb 08, 2005 at 06:26 UTC ( [id://428947]=note: print w/replies, xml ) Need Help??


in reply to Getting CGI script to send a binary file

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; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://428947]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-20 04:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found