2008/8/19 Dermot <[EMAIL PROTECTED]>:
> 2008/8/19 Carl Franks <[EMAIL PROTECTED]>:
>> 2008/8/19 Dermot <[EMAIL PROTECTED]>:
>>> sub downloadFile {
>>>
>>> my ($name, $filepath) = @_;
>>>
>>> my $length = (stat($filepath))[7];
>>> my $res = $c->response;
>>> $res->content_length($length);
>>>
>>> $res->headers->({ 'Content-Disposition' =>
>>> "attachment;filename=$name"} ); # CODE ref error
>>>
>>> $res->sendfile($filepath,0,$length); # Ok no such method but
>>> hopefully you'll get what I mean.
>>>
>>> }
>>
>> open my $filehandle, '<', $filepath
>> or die $!;
>>
>> $c->response->body( $filehandle );
>
>
> Sorry. I mustn't be making myself clear.
>
> I want the browser to offer the user a 'save as' dialogue box. The
> modperl equivalent would be the RequestIO::sendfile
>
> The above sends the contents of filepath to the browser
Ah, ok.
You should have used header().
headers() returns the HTTP::Headers object, which you were overwriting.
$c->response->header(
'Content-Disposition' => "attachment;filename=$name"
);
You'll still need the body($fh) bit to send the data, too.
Carl
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/