首先,您提供的链接不是图像。它输出..
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>AllAccessDisabled</Code>
<Message>All access to this object has been disabled</Message>
<RequestId>35DFBD44D75B45C4</RequestId>
<HostId>
n1TT+gOUuMJ3RydGND/s3QL73JJEadz/2uQutK4NNUDbEaGX6EI0Y8a/6eDHLR6H
</HostId>
</Error>
测试和工作!
下面的代码从 URL 读取图像,保存它,然后在浏览器上打开/呈现。
<?php
$image ="http://blog.stackoverflow.com/wp-content/uploads/stackoverflow-logo-300.png";
$ch = curl_init($image);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
$rawdata=curl_exec ($ch);
curl_close ($ch);
$fp = fopen("test.jpg",'w');
fwrite($fp, $rawdata);
fclose($fp);
header ("Content-Type: image/png");
readfile("test.jpg");
输出 :
或者
如果你只想渲染它.. 这样做。
<?php
readfile("http://blog.stackoverflow.com/wp-content/uploads/stackoverflow-logo-300.png");
header ("Content-Type: image/png");