8 messages in com.mysql.lists.mysqlRe: Storing Images as Blob Datatypes
FromSent OnAttachments
Peter L. Berghold18 Apr 2000 07:19 
lkeeton18 Apr 2000 08:28 
Steve Ruby18 Apr 2000 08:35 
sin...@mysql.com18 Apr 2000 08:35 
Steve Ruby18 Apr 2000 09:07 
Peter L. Berghold18 Apr 2000 09:57 
Peter L. Berghold18 Apr 2000 11:37 
Robert Goff18 Apr 2000 12:04 
Subject:Re: Storing Images as Blob Datatypes
From:Peter L. Berghold (Pet@Berghold.Net)
Date:04/18/2000 07:19:08 AM
List:com.mysql.lists.mysql

lkeeton wrote:

I have looked on the MySql Archived lists for information on storing images as BLOB's and I have failed on coming accross anything that was useful in what I

{snip!}

I am trying to acomplish much the same thing and just asked the list how to do this from a perl script using the DBI and DBD::mysql interface. So far no answers, but I will be trying experiments on my own over the next couple of days.

My thought so far:

take the image and read it into a buffer in one munch use the pack call to uuencode the info store the blob as if it were a regular string.

Your table should have a column to "remember" the original format type (.gif, .jpeg, .png, whatever) so it can be properly constituted later.

Another thought:

A web page (or generated HTML) could reference a perl script that pulls the BLOB from the database, reconstitutes it, and returns it as a stream.

<img src="http://my.site.com/cgi-bin/getimage.pl?imageid=xyzabc"> where xyzabc is some sort of key that identifies the image in the database for retrieval. The perl script would then return the stream starting with

Content-Type: image/jpeg (or whatever)

(three blank lines)

and the browser *should* display the image. Worth a try.... Not 100% sure about the last bit.