How to display base64 encoded image in HTML if it is located in a separated file?

后端 未结 4 974
悲哀的现实
悲哀的现实 2020-12-14 12:02

I have base64 encoded image. If I put it right into html it works:


But when I put all that b

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-14 12:51

    You cannot do that, I believe. The first syntax corresponds to a pseudo protocol (scheme) data: that means that the data is not to be fetched from somewhere outside, but from the attribute string itself. As the "data" is in general binary, and the attribute is text, base64 is commonly used.

    But when the data is fetched from outside the page (http server, or local filesystem), the data must come in raw (binary) form.

    You could do it with some javascript work, of course.

提交回复
热议问题