2007年02月08日 星期四 21:49
ÇëÎʸ÷룬ÓÃmod_pythonдºǫ́½Å±¾£¬ÒªÈÃÇ°¶Ëä¯ÀÀÆ÷µ¯³öÏÂÔØÎļþ¶Ô»°¿ò£¬¸ÃÔõôдÄØ£¿ÎÒÕâÑùд£¬ req.content_type = "application/octet-stream" file = open(f_path).read() ## memory leak?? return file Ç°¶ËÈç¹ûÊÇÓÃajax£¬ÒªÔõô½ÓÊÕÎļþÄØ£¿ÊÇÒªÓÃresponseText½ÓÊÕÎļþÄÚÈÝÂð?¶Ôajax²»Ê죬Çë¸÷λ°ï°ïæ¹þ¡£ -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070208/ed63d082/attachment.html
2007年02月08日 星期四 23:06
python打出一个http header 例如: Content-Type: text/html Content-Disposition: attachment: filename=xxxxx 然后读取文件内容并打印出来,浏览器就会提示文件下载,并不需要ajax. On 2/8/07, 黄翀 <huangchonggnu在gmail.com> wrote: > > 请问各位,用mod_python写后台脚本,要让前端浏览器弹出下载文件对话框,该怎么写呢?我这样写, > req.content_type = "application/octet-stream" > file = open(f_path).read() ## memory leak?? > return file > 前端如果是用ajax,要怎么接收文件呢?是要用responseText接收文件内容吗?对ajax不熟,请各位帮帮忙哈。 > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > -- -------------------------------------------------------------- WoCal生活,尽在掌握! http://kofwang.wocal.cn -------------------------------------------------------------- -------------- 下一部分 -------------- 一个HTML附件被移除... URL: http://python.cn/pipermail/python-chinese/attachments/20070208/2dd66010/attachment.htm
2007年02月09日 星期五 12:18
ÓÃÁËform±íµ¥£¬¶àл¡£ ÔÚ07-2-8£¬ÀîÑ°»¶ÔβËÁË <zhang.xiaoye在gmail.com> дµÀ£º > > python´ò³öÒ»¸öhttp header > ÀýÈç: > Content-Type: text/html > Content-Disposition: attachment: filename=xxxxx > È»ºó¶ÁÈ¡ÎļþÄÚÈݲ¢´òÓ¡³öÀ´,ä¯ÀÀÆ÷¾Í»áÌáʾÎļþÏÂÔØ,²¢²»ÐèÒªajax. > > > On 2/8/07, »ÆÁ <huangchonggnu在gmail.com> wrote: > > > ÇëÎʸ÷룬ÓÃmod_pythonдºǫ́½Å±¾£¬ÒªÈÃÇ°¶Ëä¯ÀÀÆ÷µ¯³öÏÂÔØÎļþ¶Ô»°¿ò£¬¸ÃÔõôдÄØ£¿ÎÒÕâÑùд£¬ > > req.content_type = "application/octet-stream" > > file = open(f_path).read() ## memory leak?? > > return file > > Ç°¶ËÈç¹ûÊÇÓÃajax£¬ÒªÔõô½ÓÊÕÎļþÄØ£¿ÊÇÒªÓÃresponseText½ÓÊÕÎļþÄÚÈÝÂð?¶Ôajax²»Ê죬Çë¸÷λ°ï°ïæ¹þ¡£ > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to > > python-chinese-request在lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > > > -- > -------------------------------------------------------------- > WoCalÉú»î£¬¾¡ÔÚÕÆÎÕ£¡ > http://kofwang.wocal.cn > -------------------------------------------------------------- > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070209/fc7889e7/attachment.html
Zeuux © 2025
京ICP备05028076号