0

你好,我正在尝试植入类似static.domain.com的东西,我们可以在没有 cookie 的情况下放置我们的图像。但问题是我通过 php 提供我的图像。像这样

public function getIMG( $img )
{
    if ( ! file_exists( "www-static". DS ."assets". DS ."images". DS . $img ) ) {
        throw new Exception( "No such img as $img" );
    }

    $img = "/image-static". DS ."assets". DS ."images". DS . $img;
    echo '<img src="' . $img . '" />';
}

我们还能植入它们吗?也许使用 php cookie_set 并以某种方式清除所有 cookie ?但如果我正确的话,我担心它与会议一起。

这是萤火虫的要求。

在此处输入图像描述

4

2 回答 2

1

那是使用会话时自动创建的 php 会话 cookie。

请参阅此问题以了解如何禁用它。

于 2011-03-08T06:43:44.847 回答
0

你仍然可以做你在描述中所做的事情。诀窍在于,不是检查图像是否在本地文件系统中,而是检查图像是否在远程服务器上可用。

您可能想要使用类似的东西:

$image_headers = get_headers('http://static.domain.com/image.png'); 
if (false !== strpos($image_headers[0], '200'))
     // echo image tag if the response's status code is 200

当然,不断 ping 远程服务器是一个代价高昂的过程。因此,您可能希望保留 static.domain.com 上可用的本地图像列表

于 2011-03-08T06:48:34.373 回答