[TYPO3] Display Image From MySQL Database
Dominique Feyer
dominique.feyer at reelpeek.net
Fri Sep 12 23:56:15 CEST 2008
Why do you store image in MySQL database ? It's not really efficient
in term of performance and memory usage for your application ...
See you
Dominique Feyer
Le 12 sept. 08 à 21:45, Lee M. Childress a écrit :
>
> I'm going bonkers. I am using an image tag <img
> src="render_image.php?db=0&id=317" alt="" /> to display an image
> contained in a mysql database. I am using the following script to
> display the image:
>
> /** * RENDER IMAGE * ============ */ if ($_GET['id'] && $_GET
> ['db']) { if (strtolower($_GET['db']) == '0') { $_db =
> 'events'; $new_width = 200; } if (strtolower($_GET
> ['db']) == '1') { $_db = 'recipes'; $new_width =
> 200; } $sql = new MySQL; $sql->mysql_query =
> 'SELECT image FROM ' . $_db . ' WHERE id = ' . $_GET['id'] . '
> LIMIT 1'; $sql->connect(); $_row = mysql_fetch_array
> ($sql->mysql_result); if ($_row['image'])
> { $_image = base64_decode($_row['image']);
> $width = imagesx($_image); $height = imagesy($_image);
> $new_height = $height * ($new_width/$width); $image_resized =
> imagecreatetruecolor($new_width, $new_height); imagecopyresampled
> ($image_resized, $_image, 0, 0, 0, 0, $new_width, $new_height,
> $width, $height); header('Content-type: image/jpeg'); imagejpeg
> ($image_resized); imagedestroy($image_resized); } }
>
> I keep getting a broken image. Any ideas?
>
> Thanks for your help.
> _______________________________________________
> TYPO3-english mailing list
> TYPO3-english at lists.netfielders.de
> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-english
More information about the TYPO3-english
mailing list