上传文件,,[Python]代码<!
上传文件,,[Python]代码
[Python]代码
<!DOCTYPE ><html> <head> <title></title> </head> <body> <form method="POST" action="." enctype="multipart/form-data" name="form">{% csrf_token %} 选择文件: <input type="file" name="filename" /> <br /> <input type="submit" value="上传"> </form> </body></html>------------------------------------------------------------------------------------# -- encoding=utf-8 --import settingsimport os,os.pathfrom service.common.decorator import render_tofrom django.views.decorators.csrf import csrf_exempt@csrf_exempt@render_to("upload.html")def upload_file(request,questionaire,term): if request.method == 'POST': getFile = request.FILES['filename'] fname = os.path.basename(getFile.name) if getFile: path = os.path.join(settings.MEDIA_ROOT,'report') fpath = os.path.join(path,fname) fp = open(fpath,'wb') for content in getFile.chunks(): fp.write(content) fp.close() fpath1 = os.path.join(path,questionaire.id,term.name) unzip_file(getFile,fpath1) return locals()
相关内容
- python telnet登陆RouterOS执行相关命令,并返回命令执行结
- 利用bs4获取58同城城市分类,bs4获取58同城,python beaut
- Python 处理图像几何变换,python图像几何变换,[Python]代码
- python urllib2和httplib请求的速度比较实例测试,urllib2ht
- 使用python下载网页上的flash,pythonflash,[Python]代码''
- Python 批量获取《oschina》高亮代码区域源码!,python《
- Find bridges of graph,bridgesgraph,[Python]代码#
- 用Python实现一个简单的算术游戏,python实现算术,#!/us
- 绑定修改网卡绑定关系脚本,修改网卡绑定脚本,[Pyth
- 判断图片分辨率并修改,判断图片分辨率,[Python]代码
评论关闭