html
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="f1">
<button >上传</button>
</form>
Django view
file = request.FILES.get('f1')
file.name # 上传文件的名字
with open(file.name, 'wb') as f:
for i in file:
f.write(i)
作者:Star-Hitian,转载请注明原文链接