Reputation: 1
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://www.example.com/xxx.png');
curl_setopt($curl, CURLOPT_REFERER, 'http://www.example.com');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
header('Content-type:image/PNG');
echo $result;
curl_close($curl);
The function header() didn't work, it always dispalyed binary data. Maybe because I used these codes in the middle of webpage what has existed. The webpage outputed some texts before header(), so it didn't work.
I want to get image by url, and display image directly, no need save file to disc. So how can I do ? Please help me !!!
—————————
I need set referer, so I used curl.
Upvotes: 0
Views: 620
Reputation: 1791
Use the image directly as follows:
<img src ='http://www.example.com/xxx.png'>
Upvotes: 1