Apache::ASP Powered by ModPerl & Apache Powered by Apache::ASP
Demo ASP: source.asp 2024-04-23

Source of file binary_write.htm:

use File::Basename;

if($Request->QueryString('type') eq 'gif') {
    $Response->{ContentType} = 'image/gif';
    open(FILE, 'test.gif') || die "can't open test.gif";
    binmode FILE;
    $/ = undef;
    my $data = <FILE>;
    $Response->AddHeader('Content-Length', length $data);
} else {

<!--#include file=header.inc-->

 We are going to load a gif through this
 same script as an example of doing a $Response->BinaryWrite()...

 <img src="<%=basename($0)%>?type=gif">


 Please note that if you are on Win32, you will need to 
 call binmode on a file handle before reading, if 
 its data is binary.

<!--#include file=footer.inc-->

<% } %>

view this file's source