title: How can I render a remote image with php?
body: <p>Here's a jpg: <code>http://i.stack.imgur.com/PIFN0.jpg</code></p>
  
  <p><img src="https://i.stack.imgur.com/PIFN0.jpg" alt="stackoverflow logo jpg"></p>
  
  <p>Let's say I'd like this rendered from <code>/img.php?file_name=PIFN0.jpg</code></p>
  
  <p>Here's how I'm trying to make this work:</p>
  
  <p><strong>/sample.php</strong></p>
  
  <pre><code>&lt;p&gt;Here's my image:&lt;/p&gt;
  &lt;img src="/img.php?file_name=PIFN0.jpg"&gt;
  </code></pre>
  
  <p><strong>/img.php</strong></p>
  
  <pre><code>&lt;?php
      $url = 'http://i.stack.imgur.com/' . $_GET['file_name'];
      header('Content-type: image/jpeg');
      imagejpeg($url);
  ?&gt;
  </code></pre>
  
  <p>I would expect <code>/sample.php</code> to show the image.  But this doesn't work.  All I get is a broken image.  What am I doing wrong?</p>