From: Dan Nelson Date: January 13 2003 6:58pm Subject: Re: Embedding images stored in database List-Archive: http://lists.mysql.com/mysql/129784 Message-Id: <20030113185811.GH3131@dan.emsphone.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In the last episode (Jan 13), Toomas said: > Hello List, > > Is there a simplier way to embed an image stored in BLOB field into > HTML than using 2 calls to Perl scripts - one to generate HTML and > another call from that HTML via IMG tag to retrieve and print image? > I mean, something like you do it in a multipart e-mail message? You can actually do this with HTML as well, by using the little-used "data:" URI. Try copying this into a file and loading it up in a broswer:

Demonstration of embedding GIF image directly in document

This is embedded image: It's not all that efficient, though, since the image is sent in base-64 and the server sends it on every page load (instead of letting the browser fetch it once and then cache it). If you're worried about the impact of launching a CGI every time you need to pull an image out of the database, see if your webserver has an SQL filesystem module, or something that will let you pull data straight out of the database without involving scripts at all. -- Dan Nelson dnelson@stripped