title: PHP: Show JPG from Binary
body: <p>I have a jpg blob thats been stored in an external DB and I'm looking to display that as an image via php. The issue is whenever I set the <code>Content-Type</code> to <code>image/jpeg</code> and echo out the blob I get the broken image icon when browsing to it.</p>
  
  <p>I have tried making the file from scratch via sublime and that works when I save it as a hexadecimal file so I know the data is valid.</p>
  
  <p>I have tried making the script create a file but it sets the <code>charset=us-ascii</code> so it won't get seen as a image file.</p>
  
  <p>Does anyone have any experience with raw image binary files? anyone know how I can display the image or even save it out to a file?</p>
  
  <p>Thanks in advance.</p>
  
  <p>P.S. I would provide the binary but its just too big to put on here.</p>
  
  <p>EDIT: (added some code)</p>
  
  <pre><code>&lt;?php
  header('Content-Type: image/jpeg;');
  
  $data = 'some long string of hex';
  
  
  // tried echoing it directly..
  echo $data;
  
  // and writing to a file...
  file_put_contents('test.jpg', $data);
  ?&gt;
  </code></pre>