Jay Jacobs wrote:

> I've got a form that will (should) send various formats back to the client
> depending on form values.  They may want the results back in csv, pdf or
> plain html.  The form always submits to a .html, and the browser usually
> expects an html.

My suggestion is to use mod_rewrite to create a mapping so that the
actual file name doesn't matter. I have a rule in the Apache conf file:

RewriteRule ^/reports/ /bin/report.pl [PT]

So going to <http://www.mysite.com/reports/foo.csv?param1=val1> would be
the same as going to <http://www.mysite.com/bin/report.pl?param1=val1>
except if the page is to be downloaded, the browser will use the name
foo.csv.

There's another parameter which gets passed to /reports/whatever.csv to
indicate that it should generate a csv, and send a suitable
Content-Type, but getting the 'name' right solves half the problem.

Steve

-- 
Steve Piner
Web Applications Developer
Marketview Limited
http://www.marketview.co.nz

Reply via email to