无效的文件erorr,将图像转换为base64

时间:2017-07-17 23:30:43

标签: python django

如何从图像输入中获取图像并将其转换为base64。

erorr:invalid file: <InMemoryUploadedFile: image.jpg (image/jpeg)>

def fileView(request):

    form = FileForm(request.POST or None, request.FILES or None)
    if request.method == 'POST':
        if form.is_valid:
            image = request.FILES.get('image')

            with open(image , "wb") as img:
                img.write(base64.decodebytes(image))

            request.session['image_file'] = img

            return redirect('')

0 个答案:

没有答案