2008/8/19 Dermot <[EMAIL PROTECTED]>:
> Hi,
>
> I am looking for a method to send a file in response to a request. My
> effort is below and all this does is print the file's path on the
> page. I can't set the content-disposition or see find an obvious
> method in C::Response or C::Request.
>
> Am I looking in the wrong place? Can someone point me in the right direction.
> Tia,
> Dp.
>
>
>
> 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 );


Cheers,
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/

Reply via email to