[Tutor] Sightly off topic - download file name

Irmen de Jong irmen at -NOSPAM-REMOVETHIS-xs4all.nl
Thu Mar 4 22:41:24 CET 2004


pxlpluker wrote:
> I what to dynamically create a page that has download links to file
> stored on disk.
> the part i don't know how to do (or if its possible) is to a different
> name appear in the browser DL window.
> i.e. I want the files stored with a random string but when being DL to
> have real name show in File Save dialog.
> 
> 
> Fred

This is not something Python-specific.
Have a look at the "Content-Disposition" HTTP header
(RFC 2183, http://www.faqs.org/rfcs/rfc2183.html)

For example when you add the following HTTP header to your
result message:

Content-Disposition: attachment; filename="foobar.txt"

most browsers will offer a download window for a file named
'foobar.txt'.


--Irmen



More information about the Python-list mailing list