首页 > 代码库 > Python写的一个文件上传upload
Python写的一个文件上传upload
#!/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()
#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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。