Hi Ben,
We have a runmode that does almost exactly what you want. It lets the
user download a csv file onto their PC with the correct filename. The
code we use is below.
$self->header_props( -type => 'text/csv' );
$self->header_add( '-content-disposition' => "attachment;
filename=$filename" );
Regards,
*DAVID BAXTER*
* SiteSuite Australasia*
Websites Made Easy
Tel: 61 2 9213 0500
Fax: 61 2 9212 5161
Email: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
Web: www.sitesuite.com.au <http://www.sitesuite.com.au/>
Benjamin Hitz wrote:
This is probably a vanilla CGI question, but I am working under CGIapp
so here goes.
I have a cgi::app that shows a table. I want to have a link which
generates a plain text (tab delim) version of the table, and pops up a
"save as" window.
Prior to cgi-app we just wrote a temp file on the server, and added a
link to it - this doesn't set the correct MIME type so if you click on
it it shows you the file in the browser (not what you want usually).
I have a run mode in my cgi-app to generate the file, but I seem to
have two mildly unsatisfying option:
1) write a tmp file on the server, and use redirect to get the txt
file... but I cannot seem to sent the Content-Type: on the redirect (I
even tried faking the header in the txt file).
2) change the header with $self->header('-type' ->
'application/octet-stream') and return the text in the run mode. This
gives me the "download" option (MIME type set correctly) but the file
name appears as "myscript.pl" and says it's a perl source.
Some way to set BOTH a redirect and a content-type? Or simply fake
the name name of the file?
Thanks,
Ben
--
Ben Hitz
Senior Scientific Programmer ** Saccharomyces Genome Database ** GO
Consortium
Stanford University ** [EMAIL PROTECTED]
##### CGI::Application community mailing list ################
## ##
## To unsubscribe, or change your message delivery options, ##
## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ##
## ##
## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ##
## Wiki: http://cgiapp.erlbaum.net/ ##
## ##
################################################################
##### CGI::Application community mailing list ################
## ##
## To unsubscribe, or change your message delivery options, ##
## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ##
## ##
## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ##
## Wiki: http://cgiapp.erlbaum.net/ ##
## ##
################################################################