#!/usr/bin/env python
#coding:utf-8
‘‘‘
@date:2014-11-30
@filename:simpleUp.py
‘‘‘
import web
urls=(
‘/‘,‘index‘,
‘/test‘,‘mytest‘,
‘/upload‘,‘Upload‘,
)
app = web.application(urls,locals())
class mytest:
def GET(self):
return "<b><h1>mytest</h1></b>"
class Upload:
def GET(self):
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={})
web.debug(x[‘myfile‘].filename)
web.debug(x[‘myfile‘].value)
web.debug(x[‘myfile‘].file.read())
print x[‘myfile‘].filename
print x[‘myfile‘].value
print x[‘myfile‘].file.read()
raise web.seeother(‘/upload‘)
if __name__==‘__main__‘:
app.run()Python写的一个文件上传upload
原文:http://blog.csdn.net/cuirqiang/article/details/41627769