title: PHP with Mongo DB store & view Images
body: <p>I successfully stored image files in MongoDB using PHP, when i retrieve images from Mongo db i had some problem, can anyone give the solution
  Here is my code:</p>
  
  <pre><code>&lt;?php
  $m = new Mongo(); 
  $db = $m-&gt;selectDB("example"); 
  $article = $db-&gt;articles;
  $files = $article-&gt;find();
  $gridFS = $db-&gt;getGridFS();
  ?&gt;
  &lt;table&gt;
  &lt;?php
      $i=1;
      foreach ($files as $storedfiles) {
      ?&gt;
      &lt;tr&gt;
          &lt;td width="30%"&gt;&lt;strong&gt;&lt;?php echo $i; ?&gt;&lt;/strong&gt;&lt;/td&gt;
          &lt;td width="70%"&gt;
              &lt;?php //echo $storedfiles["_id"]; ?&gt;
              &lt;?php echo "Id :".$storedfiles["_id"]; ?&gt;
              &lt;?php echo "Title :".$storedfiles["title"]; ?&gt;
              &lt;?php echo "Keywords :".$storedfiles["keywords"]; ?&gt;
  
              &lt;?php echo "Image :".$storedfiles["image"]; ?&gt;
              &lt;?php   $image = $gridFS-&gt;findOne(array('_id' =&gt; new MongoId($storedfiles["image"]))); 
  header('Content-type: image/jpg;');
              echo $image-&gt;getBytes();
      ?&gt;
  
  
          &lt;/td&gt;
      &lt;/tr&gt;
      &lt;?php
      $i++;
      }
      ?&gt;
      &lt;/table&gt;
  </code></pre>