Re: Forcing Browser to Download text file created on the fly

bcm (ix@maz.org)
Fri, 8 May 1998 15:04:24 -0700 (PDT)


On Wed, 6 May 1998, Maurice Aubrey wrote:

>> At 08:12 98/05/06 +1000, you wrote:
>> >Does anyone have any ideas on how to tell the browser to save the file
>> >with a name that is different to the CGI script that initiates the save.
>> >(Assuming Content-type: application/octet-stream\n\n )
>> 
>> That's the kicker in all of this. Although i've been using octet-stream for
>> a while, I haven't been able to give a personnalized file name... Any help
>> would be great.
>
>  Additionally, at least for Netscape 2.0 and later (I believe), you can
>include the following header:
>
>content-disposition: filename="myfilename"

i've tried that, didn't work.

>  Finally, I've heard that you can include the filename in the path info, and most
>browsers will use it.  I haven't tried this through.
>
>  http://www.mysite.com/cgi-bin/script.cgi/filename.gif

i solved this problem by using a mod_perl enabled apache to
rewrite urls. you could also use mod_rewrite.

i take a url of the form

  http://foo.com/attach/filename.doc?1,4

and turn it into

  http://foo.com/cgi-bin/attach.cgi?1,4

this gives the browser a filename but invokes the correct
request handler when the link is clicked.

| Brian Moseley |

[h] 415.487.0312  -+-  Agent of Chaos  -+-  ix@maz.org
[w] 415.543.2800  -+-   Perl Warrior   -+-  ix@criticalpath.net