Denzil Kruse wrote:
>
> --- Bob Showalter <[EMAIL PROTECTED]>
> wrote:
>
> <snip>
>
>> use CGI qw(:standard);
>>
>> open FILE, ...blah blah...
>> print header('application/octet-stream');
>> print while <FILE>;
>>
>
>
> Thanks for the help Bob! Is there another way besides
> the content-disposition to specify an attachment or
> filename? I was trying to find a way to get a file
> download box to come up to ask where to save the file
> on their local computer. With just the above, it will
> display it in the browser, and my users will just
> go...huh?
>
> Denzil
The 'header' function can take a key/value list of arguments to include
additional header lines. So you can pass your content-disposition header
as you had it before. The key here is that the content type be set to
'application/octet-stream' and that the disposition header will only
work if the client understands it, but in most cases it is worth a shot.
In one my libraries I use,
my %header_options = ( -Content_Type => 'application/octet-stream',
-Content_Length => $content_length,
);
if (defined $self->{'filename'} and $self->{'filename'} ne '') {
$header_options{-Content_Disposition} = "attachment;
filename=\"$self->{'filename'}\"";
}
It seems to have worked for me. Obviously you need to replace
$self->{'filename'} with your variable, and preferably set
$content_length with the file size.
HTH,
http://danconia.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>