You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Michael Stepanov <f....@news.francoudi.com> on 2004/11/12 17:40:04 UTC

Send ASCII file to the browser

Hi guys,

I have a small problem with sending simple ASCII file
to the browser. Inside perl module I have a method
which find and send specific file:

my $fh = new Apache::File('some_file');
my $r = Apache->request;
$r->content_type('plain/text');
$r->headers_out->set('Content-Disposition' => "attachment;
  						filename=some_file);
$r->sendfile($fname);

I call that method from a web page.
Problem: source code of the web page is added at the end of downloaded file.

Any suggestions?

Thanks in advanced.

-- 
Best regards,
Michael Stepanov
Perl/Linux Developer
Francoudi & Stephanou Ltd
Tel: +357 25-867154
Email: michaelstepanov@francoudi.com


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: Send ASCII file to the browser

Posted by Michael Stepanov <f....@news.francoudi.com>.
Chris Gamache wrote:
> This might be solution: 
> 
> $r->content_type('text/plain');

Yes, you are right!
I should be more careful!
Thanks.

> 
> 
> --- Michael Stepanov <f....@news.francoudi.com> wrote:
> 
> 
>>Hi guys,
>>
>>I have a small problem with sending simple ASCII file
>>to the browser. Inside perl module I have a method
>>which find and send specific file:
>>
>>my $fh = new Apache::File('some_file');
>>my $r = Apache->request;
>>$r->content_type('plain/text');
>>$r->headers_out->set('Content-Disposition' => "attachment;
>>  						filename=some_file);
>>$r->sendfile($fname);
>>
>>I call that method from a web page.
>>Problem: source code of the web page is added at the end of downloaded file.
>>
>>Any suggestions?
>>
>>Thanks in advanced.
>>
>>-- 
>>Best regards,
>>Michael Stepanov
>>Perl/Linux Developer
>>Francoudi & Stephanou Ltd
>>Tel: +357 25-867154
>>Email: michaelstepanov@francoudi.com
>>
>>
>>-- 
>>Report problems: http://perl.apache.org/bugs/
>>Mail list info: http://perl.apache.org/maillist/modperl.html
>>List etiquette: http://perl.apache.org/maillist/email-etiquette.html
>>
>>
> 
> 
> 
> 
> 		
> __________________________________ 
> Do you Yahoo!? 
> Check out the new Yahoo! Front Page. 
> www.yahoo.com 
>  
> 
> 


-- 
Best regards,
Michael Stepanov
Perl/Linux Developer
Francoudi & Stephanou Ltd
Tel: +357 25-867154
Email: michaelstepanov@francoudi.com


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: Send ASCII file to the browser

Posted by Chris Gamache <cg...@yahoo.com>.
This might be solution: 

$r->content_type('text/plain');


--- Michael Stepanov <f....@news.francoudi.com> wrote:

> Hi guys,
> 
> I have a small problem with sending simple ASCII file
> to the browser. Inside perl module I have a method
> which find and send specific file:
> 
> my $fh = new Apache::File('some_file');
> my $r = Apache->request;
> $r->content_type('plain/text');
> $r->headers_out->set('Content-Disposition' => "attachment;
>   						filename=some_file);
> $r->sendfile($fname);
> 
> I call that method from a web page.
> Problem: source code of the web page is added at the end of downloaded file.
> 
> Any suggestions?
> 
> Thanks in advanced.
> 
> -- 
> Best regards,
> Michael Stepanov
> Perl/Linux Developer
> Francoudi & Stephanou Ltd
> Tel: +357 25-867154
> Email: michaelstepanov@francoudi.com
> 
> 
> -- 
> Report problems: http://perl.apache.org/bugs/
> Mail list info: http://perl.apache.org/maillist/modperl.html
> List etiquette: http://perl.apache.org/maillist/email-etiquette.html
> 
> 



		
__________________________________ 
Do you Yahoo!? 
Check out the new Yahoo! Front Page. 
www.yahoo.com 
 


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html