Python论坛  - 讨论区

标题:[python-chinese] mod_python 处理文件下载,怎样让前台弹出下载对话框

2007年02月08日 星期四 21:49

=?GB2312?B?u8bBiA==?= huangchonggnu在gmail.com
星期四 二月 8 21:49:01 HKT 2007

ÇëÎʸ÷룬ÓÃ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 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年02月08日 星期四 23:06

李寻欢晕菜了 zhang.xiaoye在gmail.com
星期四 二月 8 23:06:52 HKT 2007

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 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年02月09日 星期五 12:18

=?GB2312?B?u8bBiA==?= huangchonggnu在gmail.com
星期五 二月 9 12:18:36 HKT 2007

ÓÃÁË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 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号