|
From: Chris W. <ch...@cw...> - 2005-03-16 23:40:24
|
* Cornel Ghiban (un...@gm...) [050316 09:33]:
> I'm trying to send a file to user using OI like this:
>
> sub my_download {
> # ..............
> open(F,$filepath) or return NOT_FOUND; # file not found
> my $r = $R->apache;
> $r->no_cache(1);
> $r->content_type('application/octet-stream');
> $r->headers_out->set(
> 'Content-disposition' =>
> 'attachment;filename='.$fileName);
> $r->send_http_header;
> $r->send_fd(\*F);
> close(F);
>
> return OK;
> }
>
> I get the file ok, but I also get the HTML output from OI and the
> file which is saved on the disk is not usable.
> What can I do to get only the file and nothing else?
OI already has the facility to send a file -- all you should need to
do is this:
sub my_download {
$R->{page}{send_file} = $filepath;
$R->{page}{content_type} = 'application/octet-stream';
my $r = $R->apache;
$r->no_cache(1);
$r->headers_out->set(
'Content-disposition' => 'attachment;filename='.$fileName
);
}
You can find the code where we send the file in
OpenInteract->send_static_file().
Chris
--
Chris Winters (http://www.cwinters.com)
Building enterprise-capable snack solutions since 1988
--
Chris Winters
Creating enterprise-capable snack systems since 1988
|