Skip to Content
Menu
This question has been flagged
1 Reply
7476 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
2934
0
May 20
3486
0
Oct 24
3685
1
Apr 17
3983