Frustrated, puzzled and confused: outputting images from a databa se

From: Date: Tue, 12 Dec 2000 23:20:27 +0000
Subject: Frustrated, puzzled and confused: outputting images from a databa se
Groups: php.general 
Request: Send a blank email to php-general+get-29980@lists.php.net to get a copy of this message
Hi folks, I'm storing image data (either image/gif or image/[p]jpeg) (and its mimetype) in a BLOB column of a MySQL database. I have written a PHP script to pull the image data and mime data for a particular ID in the database, and output. This does seem to be working (touch wood). Before someone suggests writing the file out and storing the filename, this won't work. We're on load-balanced servers without any file sharing means between them. My problem is that when I pull the image data from the database, I'm not sure what to do in order to output it. I've tried: <? Header("Content-Type: image/gif"); echo $imagedata; Exit(); ?> But this only seems to produce a broken image in a browser, and when I look at it on a command line it *seems* to work. Please excuse crap below: [jason@phpdev htdocs]# curl "http://<<hostname>>/dbgfx.php3?affcode=21&logotype=new" ...$OEr°IE(4'BY$ÿ¼"Hç É ')¤oere/L(_-T)³WK 7o?q'Ë Á^­HEUR0°L îà %vñ¢hh"f-°÷E...f~!?r¸!...¢cÚ:~Xâ?¨¢?,v(¡¾ý"Ø{4 ō8 8ÔB|]ô-8ü~ÙyEUR5-KìÐUOE`}r?<=D)å"TVÉCe áá È\·ÌÉø'ǝ×§'YY&Ùy÷]\Õ11 oef`Hbh>Ó&oeOEÙ5-'Y¦oe^ ¨ádã8R1ã BV#]ÆÒ"1uÈQ0,3¥S~6*ÁÊX SB LHc'GåËh½ ¤»Fé~^10 fTh´²×0e 76"} pGPÍÿz Rúò-¨À-±s8?áZ7...ÑÄ{vÉË1[jason@phpdev htdocs]# Do I need to use image functions? I thought I would be able to get by without them. Can I just echo the binary data to the browser? I'm completely puzzled. This *should* be working. Please help... Jason -- Jason Murray jasonm@melbourneit.com.au Web Design Team, Melbourne IT Fetch the comfy chair!

« previous php.general (#29980) next »