Web.py中的文件上传

啥都不说了, 上代码:

  1. import web
  2. import os
  3. import time
  4. class files:
  5.     def GET(self):
  6.         ......
  7.     def POST(self):
  8.         inp = web.input()
  9.         uploaded = inp.fh
  10.         fname = inp.filename
  11.         if uploaded:
  12.               _fl = open( os.path.join(ssPath,
  13.                                    dlPath,
  14.                                    fname), 'w')
  15.               _fl.write( uploaded )
  16.               _fl.close()
  17.         raise  web.redirect(....)

你可能感兴趣的:(web.py)