On Fri, 7 Sep 2001, Jeff Thies wrote:

> 
> As long as we are sort of on/off topic there is a question about
> retrieving images that are stored in databases that I've always wanted
> to ask.
> 
> Can you retrieve a database stored image and mix it in with regular
> HTML?
> 

The answer is no. You have to deliver an HTML page in which you
include a
call to a CGI program that retrives the image from the database, and
delivers it with the appropiate header (content type, and so).
You can't mix HTML and the image binary information.
Suppose you are using a database backend for the creation of dynamic HTML
pages. Then first you generate a page with the HTML code and deliver it.
And included in this HTML code is the code to retrive the image.
For example, suppose thar the CGI program to retrive images is called
getimage, and that each image is identified with a index number, something
like imgid=xxx. Then you would have to include HTML code like this in your
dinamically created HTML page:

<img src="/cgi-bin/getimage?imgid=1362">

Hope you get te idea.

Cheers
                Kenneth


> It seems to me that if you are going to print an image, you would have
> to print the Content type for images and would then be unable to print
> regular HTML. Am I wrong there?
> 
> Jeff 
> 
> >  The only think you might want to think about is your service
> > provider, if you are not running your own server.  How much space due they
> > allocate for your files and how much are you allowed to store in your db.
> > >From my experience, providers (at least the ones I've dealt with) always
> > limit your directory size, though they are not as limiting on your db, so
> > you must evaluate these things and see what's a more efficient long term
> > solution for you.
> > 
> > Don't forget to set LongReadLen and LongTruncOk when retrieving images, and
> > you must use placeholders when inserting them.
> > 
> > Ilya
> > 
> > -----Original Message-----
> > From: Todd Moy
> > To: dbi-users
> > Sent: 9/7/01 10:32 AM
> > Subject: Images in MySQL
> > 
> > Hello all:
> > Just a quick question concerning putting images in a database-
> > I want to add a field for images within my mysql database: how should I
> > go about doing this?
> > I have tried
> > --
> > ALTER TABLE project
> > ADD(proj_img blob binary);
> > --
> > ...to no avail. What is the correct syntax?
> > Also, is this even a good idea? Would it be better to just store a link
> > to an image within another directory? The images contained within should
> > be under 100k.
> 

Reply via email to