Skip to Content
Menu
This question has been flagged
1 Reply
8057 Views

Hi, Everyone,

I used the code:

with open('z.jpg','wb') as f:
f.write(base64.b64decode(self.file))

the 'file' is the name of Binary field which have put a photo in, but I can't open the file (z.jpg) I have got correctly.

So, Are there anyone can modify this code and make it work?

Avatar
Discard
Author Best Answer

I fixed with code:

with open('z.jpg','wb+') as f:
f.write(base64.b64decode(self.file))
Avatar
Discard
Related Posts Replies Views Activity
0
Feb 16
3648
0
May 20
4032
0
Oct 24
4550
1
Apr 17
4611