title: Forcing an image download in PHP. Works locally but breaks on live Linux server
body: <p>I am forcing the download of an image through my website.</p>
  
  <p>Forced download works fine on Apache/Windows development machine.</p>
  
  <p>However it pushes junk characters to the screen when live on my linux web server.</p>
  
  <pre><code>e.g. �����JFIF��H�H����6Exif��MM�*����
  </code></pre>
  
  <ul>
  <li>Firefox - junk</li>
  <li>Chrome - junk</li>
  <li><p>Internet Explorer 7 - displays the image in the page</p>
  
  <pre><code>$fileName = basename($filePath);
  $fileSize = filesize($filePath);
  
  
  // Output headers.
  header("Cache-Control: private");
  header("Content-Type: Image/jpeg");
  header("Content-Length: ".$fileSize);
  header("Content-Disposition: attachment; filename=".$fileName);
  
  
  // Output file.
  readfile ($filePath);                   
  exit();
  </code></pre></li>
  </ul>
  
  <p><strong>What differences might there be on my live server that would cause it to break?</strong></p>