'''拖拽图片到编辑器完成上传,并返回图片路径'''
PicBaseRoot = "static/Image/"
file_img = request.FILES.getlist('file')
for i in file_img:
image = models.Image()
random_name = str(int(random.random()*10000000000000000))
PicPath = PicBaseRoot + random_name + ".jpg"
image.ImageName = random_name + ".jpg"
image.save()
with open(PicPath, 'wb') as pic:
for c in i.chunks():
pic.write(c)
try:
message = {'path': PicPath, "status": True}
image.save()
return JsonResponse(message)
except Exception as e:
print(e)
return JsonResponse({"status": False})