Differences between revisions 2 and 4 (spanning 2 versions)
Revision 2 as of 2008-04-09 06:15:59
Size: 1056
Editor: ZoomQuiet
Comment:
Revision 4 as of 2009-11-28 14:36:07
Size: 1022
Editor: Elias
Comment: 删除对PageComment2组件的引用
Deletions are marked like this. Additions are marked like this.
Line 39: Line 39:


= 反馈 =
[[PageComment2]]

::-- ZoomQuiet [DateTime(2008-01-22T07:11:58Z)] TableOfContents

Include(CPUGnav)

1. 防盗下载支持

{{{jack139 <Jack139@gmail.com> reply-to python-cn@googlegroups.com, to "python-cn:CPyUG" <python-cn@googlegroups.com>, date Jan 20, 2008 5:19 PM subject [CPyUG:38810] Re: 如何 python实现下载功能 }}} 用django很简单,这是剪的一段,改改就可以用了:

   from os.path import splitext
   ext=splitext(this_file.filename)[1]
   response = HttpResponse(mimetype='application/octet-stream')
   response['Content-Disposition'] = 'attachment; filename="%s"' %
this_file.filename

   ## 写文件
   try:
       f = open(settings.UPLOAD_PATH+this_file.file_path,'rb')
       response.write(f.read())
       f.close()
   except Exception, detail:
       return HttpResponse('eSYS ERROR read: '+str(detail))

   return response

MiscItems/2008-01-22 (last edited 2009-12-25 07:14:02 by localhost)