微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php - 在浏览器中显示 png/image 可以在 localhost 中运行,但不能在 aws 中运行

如何解决php - 在浏览器中显示 png/image 可以在 localhost 中运行,但不能在 aws 中运行

我正在使用此代码在 uuser 网络浏览器上输出文件

header("Content-Type: image/png");
header("Content-disposition: inline; filename=".$file_name.".png;");
echo file_get_contents('data:image/png;base64,'. $file_content);

这在我的 localhost docker 环境中运行良好,但在 EC2 中它显示奇怪的字符(如下图所示)。

enter image description here

我做错了吗?

解决方法

尝试这样做:

<img src='data:image/png;base64,<?php echo base64_encode(file_get_contents($file_name.".png")); ?>'>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。