title: CakePHP: getting image from mysql BLOB To iOS
body: <p>i'm trying to get an image from database using the following code </p>
  
  <pre><code>$this-&gt;autoRender=false;
  $blob = $this-&gt;GeneralNews-&gt;findById($id,array("image_data"));
   $image = imagecreatefromstring($blob["GeneralNews"]["image_data"]); 
  
   ob_start(); //You could also just output the $image via header() and bypass this buffer capture.
   imagejpeg($image, null, 80);
   $data = ob_get_contents();
   ob_end_clean();
  
  echo '&lt;img src="data:image/jpg;base64,' .   base64_encode($blob["GeneralNews"]["image_data"])  . '" /&gt;';
  </code></pre>
  
  <p>the result can be seen in the next url 
  <a href="http://www.thedarkdimension.com/generalNews/displayImage/1678" rel="nofollow">http://www.thedarkdimension.com/generalNews/displayImage/1678</a></p>
  
  <p>but when i try to get this via iOS in </p>
  
  <pre><code> NSData * imageData = [NSData dataWithContentsOfURL:imageURL];        
   UIImage * image = [UIImage imageWithData:imageData];
  </code></pre>
  
  <p>the image that i get is empty although there is a data  in (imageData)</p>
  
  <p>i can't figure out the problem but it's most probably came from the PHP side .. cause i tried this URL 
  <a href="http://www.johnquarto.com/wp-content/uploads/2008/08/gag.jpg" rel="nofollow">http://www.johnquarto.com/wp-content/uploads/2008/08/gag.jpg</a>
  and it's ok with it.</p>