Web.py Cookbook 简体中文版 - 保存上传的文件
justjavac 发表于 2012-04-19
问题
上传文件,并将其保存到预先设定的某个目录下。
方法
import web urls = ('/upload', 'Upload') class Upload: def GET(self): web.header("Content-Type","text/html; charset=utf-8") return """<html><head></head><body> <form method="POST" enctype="multipart/form-data" action=""> <input type="file" name="myfile" /> <br/> <input type="submit" /> </form> </body></html>""" def POST(self): x = web.input(myfile={}) filedir =...