Re: file targets

Daniel Bretoi <[email protected]>
Newsgroups gmane.comp.apache.mod-ruby
Message-ID <[email protected]>
On Wed, Feb 04, 2004 at 12:06:25PM -0500, Kirk Haines wrote:
> On Wed, 4 Feb 2004, Daniel Bretoi wrote:
> 
> > r.headers_out.add("Content-Disposition:attachment","filename=blah");
> 
> r.headers_out.add("Content-Disposition","attachment; filename=blah")

thanks. This is one variation I had tried also, but didn't get it to
work.

Here is all of my code. Maybe I'm doing something else wrong:


<% require 'cgi'; @cgi = CGI.new;
r = Apache.request 
file = "/etc/passwd"; #just an example
File.open(file) { |f|
	r.content_type = "application/octet-stream"
	r.headers_out.add("Content-Disposition","attachment; filename=blah");
	r.send_http_header
	exit(Apache::OK) if r.header_only?
	r.send_fd(f)
%>

The file does not open up in a save-as dialog like I'm expecting, but
just displays as text.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.