- $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.php?path=x/x/xtest.gif”>
原创文章,作者:键盘游走者,如若转载,请注明出处:https://www.708034.com/2007/12/php%e4%b8%ad%e7%94%a8header%e5%9b%be%e7%89%87%e5%9c%b0%e5%9d%80-%e7%ae%80%e5%8d%95%e9%9a%90%e8%97%8f%e5%9b%be%e7%89%87%e6%ba%90%e5%9c%b0%e5%9d%80/