Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

file download from cgi

36 views
Skip to first unread message

Jeffrey Kunce

unread,
Feb 18, 1998, 3:00:00 AM2/18/98
to

this isn't exactly a python question - but I am trying to do it *in*
python...

My python cgi generates an ascii data file and sends it to the
client (to be saved on disk or opened in an app). I want my cgi
program to specify the name of the data file.

My best attempt is something like this:

print 'Content-type: text/x-whatever'
print 'Content-Disposition: inline; filename="'+remoteName+'"'
print
...statements printing file data

Works as advertised on Netscape Gold 3.0.
But MSIE 4.0 ignores my "remoteName" and makes up its own
file name for saving the data.

Any answers or pointers would be appreciated. Thanks.

--Jeff

Thomas Heller

unread,
Feb 19, 1998, 3:00:00 AM2/19/98
to Jeffrey Kunce
The only solution I have found (I had the same problem)
was to code the filename in the URL.
For example, selecting http://server/cgi/script/filename.ext
the browser will try to save to the file filename.ext.
Unfortunately, http://server/cgi/script?filename.ext does not work
the same way.

Hope this helps
Thomas

Jeffrey Kunce

unread,
Feb 19, 1998, 3:00:00 AM2/19/98
to

>> My python cgi generates an ascii data file and sends it to the
>> client (to be saved on disk or opened in an app). I want my cgi
>> program to specify the name of the data file.
>> ...
>The only solution I have found (I had the same problem)
>was to code the filename in the URL.
>For example, selecting http://server/cgi/script/filename.ext
>the browser will try to save to the file filename.ext.
>...

Thanks for the idea. Yes, that would work, but I need to give the
downloaded file different names based on the user's input.

I wonder if this is some sort of "security feature" of MSIE?


Mike C. Fletcher

unread,
Feb 20, 1998, 3:00:00 AM2/20/98
to

You should be able to raise an HTTP error code 303 and direct the browser to a
new (temporary) file for download which is given the correct name. Haven't done
it myself, but I seem to recall someone posting about it ages ago.

Of course, if you do it that way you need to copy the file each time, might be
better to create a CGI which takes its path-info argument and does a lookup to
see what file to push to the client given that virtual filename. (Be careful not
to open up a security hole!)

Good luck,
Mike

Jeffrey Kunce <KUN...@mail.conservation.state.mo.us> --> Thu, 19 Feb 1998
19:41:23 GMT:

...
>>The only solution I have found (I had the same problem)
>>was to code the filename in the URL.
>>For example, selecting http://server/cgi/script/filename.ext
>>the browser will try to save to the file filename.ext.
...
>
>Thanks for the idea. Yes, that would work, but I need to give the
>downloaded file different names based on the user's input.

________________________________
M i k e C . F l e t c h e r

mcfl...@golden.net
http://www.golden.net/~mcfletch/
________________________________
Design, Consultation, Training

0 new messages