urls.py:
urlpatterns={url(r'^upload/$')} 主页url(r'^$')
views.py:
def index(request):
render(request,'index.html')
templates模板文件:
新建一个index.html
结果:选择文件【】上传
一、requests库
if request.method =='POST’:request.FILES('upfile')#如果请求方式为post,则取出文件upfile
md5 = hashlib.md5(file).hexdigest()#取文件md5值解决同名问题
二、pymysql
自动创建数据库:cmd命令 python manage.py makemigrations #生成模型文件
python manage.py migrate #创建表
下载文件:file = open('file/{}'.format(md5),'rb').read()
response = HttpResponse(file)
response['content-type'] = "application/octet-stream"return response
三、setting.py
LANGUAGE_CODE = 'zh-hans'#中文
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。