import base64
class ImgOn(BASEAPI):
def post(self, request):
img = request.FILES.get("file")
data = base64.b64encode(img.read())
file_url = 'data:image/png;base64,{}'.format(data)
file_url = file_url.replace("b'",'').replace("'", '')
res = {"status": 0, "msg": "图片上传成功", "file_path":file_url}
return self.json_response(res)
数据库存储类型 建议使用 longtext 不然大一点的图片存储会失败



