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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.