This fragment is from a login-protection script I wrote to test a system I'm eventually planning to deploy on my own domain. It works on my server's FreeBSD installation, with IE5.5, NS4.xx, and NS6.xx clients.
use CGI; use CGI::Carp qw(fatalsToBrowser); sub NiceGetFile { my ($Filename) = @_; my $RawHTML = ""; if (open(FILE,"<".$Filename)) { binmode(FILE); my $Position = sysseek(FILE,0,2); if ($Position) { sysseek(FILE,0,0); sysread(FILE,$RawHTML,$Position); } close(FILE); } return $RawHTML; } # probably should set the CGI config to blast excessive # POSTS here my $DynPage = new CGI; # Do anti-leeching code immediately my $file = 'Demo.zip'; my $ZIPFile = &NiceGetFile('ZIP/'.$file); unless($ZIPFile) { # inform user and email admin # .... }; # NOTE: could use Content-MD5 header here # NOTE: change the type-header to the real MIME-type print $DynPage->header(-type=>'application/zip', -Content_Length=>length($ZIPFile)); binmode( STDOUT ); print $ZIPFile;
In reply to Re: Delivering an image to a client browser/PC
by zaimoni
in thread Delivering an image to a client browser/PC
by MrCromeDome
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |