php破解防盗链

 1:设置所有图片src代理到自己的接口,如下:接受get请求的showpic接口

<img src="/showpic?url=https://www.domain.com/faq/uploads/images/20181123/1542965210123968.png" >

2:图片服务端转发

public function showpic(Request $request)
{
    $url = $request->get('url', false);
    if ($url){
        header('Content-type: image/jpeg');
        echo file_get_contents($url);
    }
}
发布了20 篇原创文章 · 获赞 8 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/web_snail/article/details/90412711