请求图片时如何获取Referer信息?

发布于 2024-09-27 05:25:43 字数 45 浏览 2 评论 0原文

我应该读取图像(使用 php)然后在抓取标题时回显它吗?或者还有别的办法吗?

Should I read an image (with php) and then echo it while grabbing the header? Or there is another way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风追烟花雨 2024-10-04 05:25:43

您想要外部图像的引用信息吗?这应该始终是您的服务器发送的任何内容。

但是,如果您正在讨论服务器上有一个应该获取引荐来源网址信息的图像文件,您可以这样做

 <?php
 // Possibly use mod_rewrite so point your image here

 $referrer = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : NULL;
 // Save the referrer somewhere

 header('Content-Type: image/png');

 readfile('image.png');

You want referrer information of an external image? That should always be whatever your server sends.

However, if you are talking about having an image file on your server that should get referrer information, you could do

 <?php
 // Possibly use mod_rewrite so point your image here

 $referrer = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : NULL;
 // Save the referrer somewhere

 header('Content-Type: image/png');

 readfile('image.png');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文