【发布时间】:2017-04-25 14:04:47
【问题描述】:
这就是我正在做的检查文件是否存在并在页面中回显,但是页面显示旧图像即使它已经被另一张图像替换它只是显示旧图像,但是新图像在那里并且旧图像已被同名的新图像替换。
<?php
$dir = 'up/images/'.$_SESSION ['username'].'.png';
if (file_exists($dir)) {
//echo "ok";
echo '<img src="up/images/'.$_SESSION['username'].'.png" class="img-responsive img-thumbnail" width="200px;" height="200px;">';
} else {
//not found
echo '<img src="img/user-icon-yellow.png" class="img-responsive img-thumbnail" width="200px;" height="200px;">';
}
?>
看起来像是缓存问题之类的。
【问题讨论】:
-
用 PHP 设置缓存头。 stackoverflow.com/questions/13640109/…
-
您能否重新表述您的问题,您的问题根本不清楚。
-
为了快速测试,您可以通过在图像的“查询字符串”中添加随机字符串来欺骗浏览器/ISP 缓存... imagename.php?SomethingRandomHere
标签: php caching file-exists