The display of some images through the readfile does not work

23 views Asked by At

I have this simple function that I use to display images on a website (due to mixed content) but it doesn't work for this particular one. How to view it?

Code:

<?php
$remoteImage = "http://data.rcm-pelikan.cz/products2/KAV0152&5/b_0_779bc.jpg";
$imginfo = getimagesize($remoteImage);
header("Content-type: ".$imginfo['mime']);
readfile($remoteImage);

Edit: Solution:

$remoteImage = "http://data.rcm-pelikan.cz/products2/KAV0152&5/b_0_779bc.jpg";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $remoteImage);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$res = curl_exec($ch);
$rescode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
curl_close($ch) ;

header("Content-Type: $contentType");
echo $res;
0

There are 0 answers