Reputation: 6570
I have HTML code like this to call a PHP image proxy
<img src="http://serverA.com/my_proxy.php?img=http://serverB.com/xyz.jpg" />
and in my_proxy.php, the code is following:
header('Content-type: image/jpeg;');
$a = file_get_contents($pic);
echo $a;
But for some cases, I want to use the image URL directly (http://serverB.com/xyz.jpg) so the HTML code is actually pulling down the image from the URL directly. Is it possible to do this by changing the code in my_proxy.php (not the HTML)?
Upvotes: 2
Views: 2816
Reputation: 449843
You can do a header redirect which will instruct the browser to fetch the image from the remote location.
header("location: ".$_GET["img"]);
die();
Upvotes: 2