According to the docs, I should be able to just use picb.addImage(s) where picb is my picture box and s is the base 64 string. Looking at the first link, I’m not sure if I need to decode the string or not - I’ve tried both ways with no luck.
Any chance you could show me exactly what code you are using? I’ve tried about 6 different ways, and it’s just not working. Not sure where I’m going wrong.
If req.status = 200 Then
r = req.responseText
'MsgBox(r, vbOKCancel)
pbScore.getContext("2d")
pbScore.addImage(r)
Else
MsgBox ("ERROR: Refresh couldn't reach the server")
End If
This is what I have so far, and it’s not working. If I uncomment the MsgBox I do get the full base 64 string required.
If you are downloading the image then the base 64 string may not be fully downloaded just yet. Add a pause or a way to ensure it has fully downloaded. Try a smaller file size and see.
I should mention, this is stored in a database, I’m accessing the string via a php script and ajax. So there should be no way I’m getting partial data.
Ah yes…you did. Hmmmm…can you test out the string by hard coding the base64 string to the r variable? If that works it could be the string maybe introducing characters that are stripped out when passed to the msg box.
So after much mucking about, and having not touched this code in the last 6 weeks, I’ve finally got it working - thanks to everyone that helped.
The final solution, and I still don’t really understand the under the hood workings was adding an ImageBox and then using the following code (ignore the req.status etc if you aren’t obtaining your picture data via an Ajax call):
If req.status = 200 Then
r = req.responseText
Image1.innerHTML = "<img src='" & r & "'>"
pb = pbScore.getContext("2d")
pb.addImage(r)
Else
MsgBox ("ERROR: GetPicture couldn't reach the server")
End If
Having trouble pulling base64 code from a databas and showing it in either a picture box or an image. I used this code after making sure the image was being returned from the database (see picture). No image displayed in either control. Thoughts?