base64 encode image blob not showing in IE

2019-03-06 03:27发布

问题:

  echo '<img src="data:image/jpg/png/jpeg;base64,' . base64_encode( $row['image'] ) . '" height="150" />';

This is showing up images great in firefox, safari and chrome, but in internet explorer it shows a nice red cross, and I assume it is because of the encoding?

回答1:

Try replacing data:image/jpg/png/jpeg; with either data:image/jpeg; or data:image/png; depending on the format of the image. You can't expect it to be both a PNG and a JPEG.



回答2:

Most likely old IE or too big image for IE8.

IE7 and below definitely don't support it. IE9 support inline images just fine. I IE8 have limited support. - Check out http://en.wikipedia.org/wiki/Data_URI_scheme for list.