2010-10-23 66 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