使用PHP中使用相同的URL之前,圖像被改變後,下載遠程圖像,下載同一張照片,即使源是不同的。圖像正在被緩存的地方。
這個問題不是瀏覽器緩存,因爲我通過FTP直接通過Windows資源管理器查看照片。
例
下午1點00:下載圖片URL A - >下載照片甲
下午1:30:照片A變更至照片B,但照片URL保持相同
2 :00pm:再次下載照片URL A - >下載照片A(但應該是照片B)
我的下載腳本
function resampimagejpg($forcedwidth, $forcedheight, $sourcefile, $destfile)
{
$fw = $forcedwidth;
$fh = $forcedheight;
$is = getimagesize($sourcefile);
if($is[0] >= $is[1])
{
$orientation = 0;
}
else
{
$orientation = 1;
$fw = $forcedheight;
$fh = $forcedwidth;
}
if ($is[0] > $fw || $is[1] > $fh)
{
if(($is[0] - $fw) >= ($is[1] - $fh))
{
$iw = $fw;
$ih = ($fw/$is[0]) * $is[1];
}
else
{
$ih = $fh;
$iw = ($ih/$is[1]) * $is[0];
}
$t = 1;
}
else
{
$iw = $is[0];
$ih = $is[1];
$t = 2;
}
if ($t == 1)
{
$img_src = imagecreatefromjpeg($sourcefile);
$img_dst = imagecreatetruecolor($iw, $ih);
imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $iw, $ih, $is[0], $is[1]);
if(!imagejpeg($img_dst, $destfile, 95))
{
exit();
}
return true;
}
else if ($t == 2)
{
copy($sourcefile, $destfile);
return true;
}
}
什麼是「我在看照片直接」是什麼意思? – arkascha
Apache可以緩存圖像,這取決於設置。這同樣適用於瀏覽器。 – jeroen
@arkascha - 我已經通過FTP將照片複製到本地機器,並通過Windows資源管理器打開它。 – BDS1400