[thelist] Re: Browser detection and save file as

Glenn Hunt ghunt at sympatico.ca
Wed Sep 19 08:57:48 CDT 2001


 From my initial email:

<cfheader name="Content-disposition" value="inline;

You will notice that I did have the filename attribute in the
Content-disposition section.

On another note, the Internet Explorer 5.5 SP1 issue was resolved in
SP2. See this:


Glenn Hunt
ghunt at hds.ca

-----Original Message-----
From: thelist-admin at lists.evolt.org
[mailto:thelist-admin at lists.evolt.org] On Behalf Of Kevin Martin
Sent: Wednesday, September 19, 2001 9:04 AM
To: thelist at lists.evolt.org
Subject: [thelist] Re: Browser detection and save file as

Thanks to Greg's pointer on how Cold Fusion does it, I was able to make
a perl CGI to do the same thing.  It's basically a shotgun marriage of
my very first CGI (provided here by a kind soul) with a perl push-a-file

routine that is normally used to send CA certificates. :-)

Got a tip from Microsoft on how to fix the content-disposition header,
to override IE's insistence on saving the file as 'download.cgi' -- 
it now appears to work in both IE 5 and Netscape.

It needs some bulletproofing, of course, but here's what it looks like:

8<------ clip here
## Syntax: http://mysite/cgi-bin/download.cgi?username=filename
my $user_dir = "/home/www/$params[0]";
my $user_file = $params[1];
my $send_file = "$user_dir/$user_file";

##  Uncomment to debug in browser:
#print "Content-type: text/html\r\n\r\n";
#print "<html><body>";
#print "P0: ", $params[0], " P1: ", $params[1], "\r\n";
#print "SF: ", $send_file, "\r\n";
#print "</body></html>";

my $data = "";
open(AFILE, "<$send_file");
while(<AFILE>) { $data .= $_; }
print "Content-type: application/x-unknown\r\n";
print "Content-disposition: inline; filename= ", $user_file, "\r\n";
print "Content-length: ", length($data), "\r\n\r\n$data";


# end of download.cgi
8<------ clip here

Kevin "digger" Martin <evolt at brasscannon.net>

For unsubscribe and other options, including
the Tip Harvester and archive of TheList go to: http://lists.evolt.org
Workers of the Web, evolt ! 

More information about the thelist mailing list