Mike,
A CGI program can generate any type of content but you have
to set the
HTTP headers correctly and correctly generate the content.
Also, there's
a content-disposition header that you can use to force the
browser to
display the save/open dialog and specify the file name.
Here's an
example of the headers I send when I generate a CSV file:
Content-type: application/msexcel-comma
Content-encoding: ebcdic
Expires: Tues, 01 Jan 1980 00:00:00 GMT
content-disposition: attachment; filename=upcoming editions
list.csv
If you translate the content to ASCII first, you don't need
to set the
Content-encoding header but this is the less programming
work way to
make sure the delivered content is readable.
Matt
-----Original Message-----
From: web400-bounces midrange.com [mailto:web400-bounces midrange.com]
On Behalf Of Mike Cunningham
Sent: Tuesday, March 14, 2006 11:05 PM
To: Web Enabling the AS400 / iSeries
Subject: [WEB400] using rpg cgi to send a .csv or .rtf file
I have done some RPG CGI to sent html files but I would now
like to send
the user a .csv file that will open in Excel or a .rtf file
that will
open in Word or a .vcs file that will open in Outlook. Is it
possible to
use the same RPG CGI technique to do this (e.g. load a base
file from
the IFS and use the CGI commands to replace the variable
data and then
send the file like it was HTML) ? Or would I need to save
the file back
to the IFS in a directory that the Apache server can serve
from and then
do an HTML redirect to get he users browser pointed to that
file ? In my
case I want to be able to let a student click on a button on
a web page
and then convert the students class schedule into a .vcs
file (already
have that code) that will be sent immediately and present
the student
with the normal "Open" or "Save"
prompt from their browser.
--
This is the Web Enabling the AS400 / iSeries (WEB400)
mailing list
To post a message email: WEB400 midrange.com
To subscribe, unsubscribe, or change list options,
visit: htt
p://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request midrange.com
Before posting, please take a moment to review the archives
at http://archive.mi
drange.com/web400.
--
This is the Web Enabling the AS400 / iSeries (WEB400)
mailing list
To post a message email: WEB400 midrange.com
To subscribe, unsubscribe, or change list options,
visit: htt
p://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request midrange.com
Before posting, please take a moment to review the archives
at http://archive.mi
drange.com/web400.
|