Load Base64 to image?

So I managed to save an image to a database as a Base 64 string… but I am now having a problem loading it.
Does this look right? The server programs returns only the Base64 text string. It looks to me like the SRC tag is expecting a URL instead of a string encoded image.

My error is: Failed to load resource: net::ERR_INVALID_URL

req = Ajax("loadimage.aspx", "POST", "LocationId=" & LocationID)
If req.status = 200 Then
  img2.src = req.responseText
  sc.drawImage(img2,0,0)
  MsgBox "Stored image loaded"
Else 'failure
  'handle error here
End If

What are you getting in req.status?

If it isn’t 200, you have a problem with your Ajax call or server.

I just fixed it by doing this to the line that assigns the text string:

img2.src = decodeURI(Trim(req.responseText))

:slight_smile:

I have trouble loading the image. How is the code in the php? Thank you