接口获取文件流,在前端展示的例子
时间:2021-09-03 20:11:52
收藏:0
阅读:12
如果返回图片地址 前端直接展示就可以了,但如果是文件流
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
评论(0)