如果它位于一个分隔的文件如何显示的base64恩在HTML codeD映像? [英] How to display base64 encoded image in HTML if it is located in a separated file?
问题描述
我有恩的base64 codeD映像。如果我把它的权利到HTML工作原理:
I have base64 encoded image. If I put it right into html it works:
<img src="data:image/png;base64,..."/>
但是,当我把所有的内容的base64到一个分隔的文件,它不会:
But when I put all that base64 content into a separated file, it doesn't:
<img src="image.base64.txt"/>
我试图改变扩展.png格式,但它并不能帮助。任何想法?
I tried changing extension to .png, but it doesn't help. Any ideas?
推荐答案
您需要发送正确的内容类型,内容编码和charset HTTP头文件一起。注意,它们是数据的所有部分:URI方案为好。你真的应该有内容类型和编码之间的的charset = UTF-8
或类似的条款:
You would need to send the correct Content-type, Content-encoding and charset HTTP headers along with the file. Note that they are all part of the data: URI schema as well. You really should have a charset=utf-8
or similar clause between the content-type and the encoding:
url(data:image/png;charset=utf-8;base64,...);
这篇关于如果它位于一个分隔的文件如何显示的base64恩在HTML codeD映像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!