You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Scott Alexander <mo...@humak.edu> on 2005/05/17 13:30:40 UTC
Apache::File and setting filename
Hi,
Is it possible with Apache::File to set the name of the filename?
(Apache/1.3.31 (Unix) mod_perl/1.29 configured)
I have
print "Content-type: application/octet-stream\n\n" ;
$file = "myfile_to_send.doc" ;
$fh = Apache::File->new($file) or warn "Can't open $file $!";
$r->headers_out->set("Content-Disposition" => "inline; filename=$file")
; $r->send_http_header ;
$r->send_fd($fh) ;
It sends the file ok, the user is prompted to save the document as the
same name of the action of my htm form.
I want to have in the interface two links for opening a file: one to
open and one to download
Regards
Scott
Re: Apache::File and setting filename
Posted by Scott Alexander <mo...@humak.edu>.
Scott Alexander wrote:
> Hi,
>
> Is it possible with Apache::File to set the name of the filename?
> (Apache/1.3.31 (Unix) mod_perl/1.29 configured)
For the record:
$fh = Apache::File->new($file) or warn "Can't open $file $!";
$r->content_type('application/octet-stream');
$r->headers_out->set('Content-Disposition' => "attachment;
filename=$file");
$r->send_http_header ;
$r->send_fd($fh) ;
works fine.
Scott
>
> I have
>
> print "Content-type: application/octet-stream\n\n" ;
> $file = "myfile_to_send.doc" ;
> $fh = Apache::File->new($file) or warn "Can't open $file $!";
>
> $r->headers_out->set("Content-Disposition" => "inline;
> filename=$file") ; $r->send_http_header ;
> $r->send_fd($fh) ;
> It sends the file ok, the user is prompted to save the document as the
> same name of the action of my htm form.
>
> I want to have in the interface two links for opening a file: one to
> open and one to download
>
> Regards
> Scott