Hi, I searched through the archives and didn't find a solution to this problem I'm encountering so hopefully someone here will know what it is. I'm trying to get the contents (image) of a MySQL blob field and output it. However, it won't display properly.
I have modified my code so that it just echos the data that it retrieves from the database: function download($id = null) { Configure::write('debug', 0); if ($id != null) { $pic = $this->Schoolpicture->findById($id); echo $pic['Schoolpicture']['content']; } exit(); } This produces the result shown here (for picture 6): http://www.ignitenation.org/index.php/schoolpictures/download/6 I also have another test script that bypasses all the CakePHP structure. It just retrieves the data and outputs it: <?php error_reporting(E_ALL); $my_table = 'schoolpictures'; $my_server = '----'; $my_user = '----'; $my_pwd = '----'; $my_name = '----'; $my_link = mysql_connect($my_server, $my_user, $my_pwd) or exit('Could not connect (' . mysql_errno() . '): ' . mysql_error ()); $my = mysql_select_db($my_name, $my_link) or exit('Could not select database (' . mysql_errno() . '): ' . mysql_error()); $row = mysql_fetch_array(mysql_query("SELECT content FROM $my_table where id=6")); print $row['content']; ?> You'll see that the result (for the same image 6) found at the following link looks quite different: http://www.ignitenation.org/test.php If you do a view source, the first link has some whitespace before the data whereas this one does not. Also, it looks like the data is encoded differently. If I add the proper header (Content-type: image/ gif), test.php will display my image properly. I suspect that the whitespace and/or the different encoding is the source of the problem, but I have no idea what could be causing that. Thanks for reading this long post and for any insight that you might be able to provide on this issue! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---