DJANGO 上传 image
1. html:
<input type="file" name="logo_path"/>
2. views:
logo_path = request.FILES.get('logo_path', '')
bf = logo_path.file.readlines()
f = file('/home/username/abc.jpg', 'wb')
for b in bf:
f.write(b)
f.close()
本文介绍了一个简单的Django应用中如何实现图片上传功能。通过HTML表单接收文件,并使用Python处理上传的图片文件,将其保存到指定路径。该教程适合初学者理解Django处理文件上传的基本流程。
DJANGO 上传 image
1. html:
<input type="file" name="logo_path"/>
2. views:
logo_path = request.FILES.get('logo_path', '')
bf = logo_path.file.readlines()
f = file('/home/username/abc.jpg', 'wb')
for b in bf:
f.write(b)
f.close()
698
1932

被折叠的 条评论
为什么被折叠?