#!/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()
时间: 2024-11-23 19:33:38