开发者

Prompt user to save my desired text file name

I wish when the user clicks on a link say.

http://www.xyz.com/dynamic-text.py

The browser will prompt user to save the text file.

The following script will make browser to prompt user to save 开发者_运维技巧dynamic-text.py. I wish to prompt user to save some-file-name.txt. How can I do so?


dynamic-text.py

#!c:/Python27/python.exe -u

print "Content-type: text/text"
print

print "This is Text File"


You can send the Content-Disposition HTTP header:

print "Content-Type: text/plain"
print "Content-Disposition: attachment; filename=some-file-name.txt"
print

Also note that you should use the text/plain content type instead of text/text which, to my knowledge, doesn't exist.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜