天天看點

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(....)