復制代碼 代碼如下:
<?php
$path=$_GET["path"];
$cacheimgname=str_replace("/","_",$path);
$localimg="upimg/".$cacheimgname;
if ((file_exists($localimg)))
{
$httpurl=$localimg;
}
else
{
$httpurl="http://www.imageserver.com/".$path;
@copy($httpurl,$localimg);//緩存圖片!
}
header("Locationhttpurl");
exit;
?>
調用它類似這樣:
復制代碼 代碼如下:
<img src="img.php?path=x/x/xtest.gif">