2010-10-23 65 views
1

有没有办法显示外部图像与PHP缓存?带缓存的PHP(外部)安全映像?

我想显示图像,如: www.domain.com/safe_image.php?url=external.site.jpg

基本上像什么Facebook并。

达到这个目的的最佳方法是什么?

谢谢。

编辑

现在这是我的代码:

$image_url = $_GET['url']; 

$ch = curl_init(); 
$timeout = 0; 
curl_setopt ($ch, CURLOPT_URL, $image_url); 
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); 

// Getting binary data 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); 

$image = curl_exec($ch); 
curl_close($ch); 

// output to browser 
header("Content-type: image/jpeg"); 
print $image; 
+0

好,缓存它们本地。你的问题到底是什么?如何获取图像?如何实现缓存? – 2010-10-23 13:05:59

+0

我的问题是如何缓存它?我用我的实际代码编辑了这篇文章。 – PGZ 2010-10-23 13:11:58

回答

1

检查我的答案在Images caching in browser - app-engine-patch aplication这是蟒蛇,但我相信你会得到的想法

+1

他正在谈论图像的外部链接,而不是本地存储的图像。您的帖子是指存储在GAE数据存储区中的图像。 – 2013-02-07 22:42:14