准备做一个数据汇总系统,需要将数据以excel表形式批量上传至数据库。
前端html代码:
<form name="form1" action="/update/" method="POST" ,enctype="multipart/form-data">
<p>
<input type="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,.csv" name="update">
<input type="button" value="提交" onclick="form1.submit();">
views视图文件:
if request.method == "POST":
wp=request.FILES.get('update')
wp=wp.read()
上传后页面提示错误:
'NoneType' object has no attribute 'read'
感觉文件没有上传到后台,不知道该怎么改了