Firefox和Chrome不会去code的base64图片或PDF文件 [英] Firefox and Chrome won't decode base64 image or pdf files

查看:346
本文介绍了Firefox和Chrome不会去code的base64图片或PDF文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过使用数据URI方案去code一个base64连接上的浏览器$ C $光盘镜像。

I'm trying to decode a base64 encoded images on the browser by using the data uri scheme.

这是我的HTML如下:

This is what my html looks like:

<img src="data:image/png;base64,base64_string_here" 
  alt="base64 image name" width="600" height="400" border="1" />

Chrome和Firefox都无法去code这些图像,并显示默认的图像无法加载的形象代替。我已经验证了我传递到浏览器的base64图像是正确的。事实上Safari一直没有问题显示相同的图像。

Chrome and Firefox are unable to decode these images and display the default "image can't load" image instead. I've verified that the base64 images I'm passing to the browser are correct. In fact Safari has no problems displaying the same images.

我试图让浏览器脱code类似的base64 EN codeD PDF格式,而非,但是这也不能工作。 (同样,它并没有在Chrome和Firefox的工作,但在Safari上的工作。)

I tried getting the browsers to decode similar base64 encoded pdfs instead, but this did not work either. (Again, it didn't work on Chrome and Firefox but worked on Safari.)

<img src="data:application/pdf;base64,base64_string_here" 
  alt="base64 pdf name" width="600" height="400" border="1" />

Chrome版本:18.0,FF版本:11.0

Chrome version: 18.0, FF version: 11.0

有谁知道什么可能是错在这里? (如果它有助于在清一色为Base64 EN codeD映像,我试图显示是USPS货运标签)。

Does anyone know what could be wrong here? (If it helps at all- the base64 encoded images I'm trying to display are USPS shipping labels).

推荐答案

在实际上,即使您提供正确的MIME类型,浏览器,Firefox和Opera不支持原生。TIF文件:他们需要一个插件来对付他们。

In fact, even if you supply correct MIME type, Chrome, Firefox and Opera do not support .TIF files natively: they require a plugin to deal with them.

有是用于图像浏览器支持有用的摘要文件在这里: HTTP://en.wikipedia。组织/维基/ Comparison_of_web_browsers#Image_format_support

There's a useful summary of browser support for image files here: http://en.wikipedia.org/wiki/Comparison_of_web_browsers#Image_format_support

这篇关于Firefox和Chrome不会去code的base64图片或PDF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆