tags:

views:

12

answers:

1

Hello,

Is there a way to display external images with PHP having cache?

I want display images like: www.domain.com/safe_image.php?url=external.site.jpg

Basically like what Facebook does.

What's best way to achieve this?

Thanks.

Edit

This is my code now:

$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; 
A: 

Check my answer at http://stackoverflow.com/questions/2185449/images-caching-in-browser-app-engine-patch-aplication it is for python but I am sure that you will get the idea

Ilian Iliev