Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • The 2nd answer from the link should work. If you get unexpected token with your json, you should check if your json is valid (you can do that here: jsonlint.com) if it is not valid, why? In general i think using base64 for images is a bad idea and the best way would be to provide an api endpoint where the browser can download that image as binary so that you can just use the link to the image in the img src. That would be more complicated to implement though Commented Mar 24, 2019 at 3:00
  • You're not understanding how HTML and HTTP work. The src property of an image doesn't contain the bytes of the image. It contains the URL of the image. When the browser finds an <img src="/foo/bar"> in the HTML, it sends an additional GET request to /foo/bar, and the server is then supposed to send a response with the bytes of the image as the body, and the content type of the image in a header. Commented Mar 24, 2019 at 9:17
  • @x4rf41 I would like to implement without using base64, can you please guide me on how to implement in better way even if it is complicated? Commented Mar 24, 2019 at 12:37
  • @x4rf41 the return string after I converted the data from bytes to base64 is very big and jsonlint.com is saying it is invalid. Commented Mar 24, 2019 at 12:49