如果返回图片地址 前端直接展示就可以了,但如果是文件流
1.
/**
* 图片预览
* @param string $file_path 文件
* @return mixed
*/
public function imgview($file_path)
{
header(‘Content-type:image/png‘);
echo file_get_contents($file_path);
exit();
}
通过路由访问这个即可
返回结果返回header的内容类型
原文:https://www.cnblogs.com/enjoycml/p/15223047.html