问题描述
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 中它显示奇怪的字符(如下图所示)。
我做错了吗?
解决方法
尝试这样做:
<img src='data:image/png;base64,<?php echo base64_encode(file_get_contents($file_name.".png")); ?>'>