php image base64编码无法正常工作

时间:2017-05-17 17:52:32

标签: php image base64

我在我的工作中遇到了一个问题,当我使用完整网址时,base64编码无效。但是我设法让它与相对路径一起工作。

这里的代码只能使用相对路径:

$type = pathinfo($this->logo_path);
$data = file_get_contents($this->logo_path);
echo "data:image/" . $type . ";base64," . base64_encode($data);

$ this-> logo_path ===" http://domain-name/assets/img/logo.png", $ data === NULL

这里有人有解释吗?我需要转换图像以将页面放在pdf文件中。我能用一个布尔变量解决我的问题,确定我是否需要base64转换,但我想了解原因。

0 个答案:

没有答案