title: Storing / Extracting images from database with php
body: <p>I am using PHP 5.3.5 and postgreSQL. I am storing and extracting images from database. </p>
  
  <p>For storing i am doing this:</p>
  
  <pre><code> $escaped_data = base64_encode(file_get_contents($_FILES['fileUpload']['tmp_name']));
   $fileModel-&gt;setBinary_Data($escaped_data);
  </code></pre>
  
  <p>It's working, i received the image in my database (Bytea field).</p>
  
  <p>The problem is to extract this, i am trying this code to extract my images:</p>
  
  <pre><code>$file_info = $fileModel-&gt;getBinary_Data($id_file); // This function return the binary_data of the image
  
  header('Content-Type: image/jpeg;base64');
  header('Content-Disposition: attachment; filename=' . $file_info['_name']);
  base64_decode($file_info['binary_data']));
  </code></pre>
  
  <p>When i download the image, i can't see the image...</p>
  
  <p>With echo in:</p>
  
  <pre><code>echo base64_decode($file_info['binary_data']);
  </code></pre>
  
  <p>This happen:</p>
  
  <p><a href="http://imageshack.us/f/18/encodez.jpg/" rel="nofollow">http://imageshack.us/f/18/encodez.jpg/</a></p>
  
  <p>After, i am trying using the function stream_get_contents inside base64_decode, but doens't work.</p>
  
  <p>Someone know how i can download my images with php?</p>
  
  <p>Thanks anyway...</p>