微信小程序图片保存到本地服务器
img_front = request.FILES.get("img_front","") # 正面图片 img_front_name, img_front_url = receive_image(img_front) # 正面图片 return JsonResponse(xxxxxxxx) def receive_image(image): ''' 微信小程序图片保存到本地 :param image: 图片 :return: ''' img_front_name = f"{time.time()}{uuid4()}{time.time()}".encode("utf8") img_front_name = f"{hashlib.md5(img_front_name + 'img_front'.encode('utf8')).hexdigest()}.jpg" img_front_url = os.path.join(settings.MEDIA_ROOT, img_front_name) with open(img_front_url, 'wb') as f: for chunk in image.chunks(): f.write(chunk) return img_front_name, img_front_url