title: file_get_contents not working on production server, fine on local
body: <p>I have a PHP script that fetches an image from a remote server so that I can manipulate it using HTML5 canvas API.</p>
  
  <pre><code>&lt;?php
  if ((isset($_GET['url']))) {
      $url = $_GET['url'];
      $file_format = pathinfo($url, PATHINFO_EXTENSION);
      try
      {   
          header("Content-Type: image/$file_format");
          header("Content-disposition: filename=image.$file_format");
          $img = file_get_contents($url);
          echo $img;
      }
  
      catch(Exception $e)
      {
          echo $e-&gt;getMessage();
      }
  }
  
  else die('Unknown request');
  ?&gt;
  </code></pre>
  
  <p>A typical request would look like this: </p>
  
  <pre><code>fetch_image.php?url=http://example.com/images/image.png
  </code></pre>
  
  <p>Everything works fine on my local server but the production server gives me this error: </p>
  
  <blockquote>
    <p>NetworkError: 500 Internal Server Error.</p>
  </blockquote>
  
  <p>The error log registers this message: </p>
  
  <blockquote>
    <p>PHP Warning:  Cannot modify header information - headers already sent.</p>
  </blockquote>
  
  <p>I have tried some of the suggestions but its not working:</p>
  
  <pre><code>allow_url_fopen = 1
  </code></pre>