| Joe Makowiec 2005-03-28, 6:35 pm |
| On 23 Mar 2005 in macromedia.dreamweaver, Affen wrote:
> I am struggelig to display images stored in a mysql database
> through PHP and
> Dreamweaver. The images are uploaded by using the mysql Query
> Browser and displays fine here. In Dreamweaver MX I have created a
> database connection to MySQL, and created a recordset in the
> bindings panel. By draging fields from the bindings panel I get
> all fields to display their content except the image field which is
> of type MEDIUMBLOB - this field displays as a jumble of text and is
> of course the binary representation of the picture. Question is -
> how do i get Dreamweaver to display the image as a jpg and not as
> binary data?
> This is the only code inserted by dragging the fields from bindings
> panel:
>
> <?php echo $row_ShowPic['PicNum']; ?>
> </p>
> <p><?php
> echo $row_ShowPic['Image'];
> ?>
It would be a whole lot easier if you were to store the filename in the
database, and use that to display an already-uploaded image. If it's a
security issue, what you'd have to do is create a separate PHP script
to display the image, thus:
<?php do { ?>
<p><img src="showpicture.php?id=<?php echo $pictureid ?>"></p>
<?php } while (whatever) ?>
where showpicture.php is a script to display the contents of the blob
field; see
http://us4.php.net/manual/en/function.imagejpeg.php
http://us2.php.net/imagecreatefromstring
for more information.
--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php
|