On Monday, October 7, 2002, at 05:39 PM, Chris Devers wrote:
>> I need to load a graphic file, especify, files .gif and .jpg. in >> MySQL. >> Is posible this in MySQL? how? Is a normal file? > > Yes, it is possible using the BLOB / MEDIUMBLOB / LONGBLOB family of > MySQL > data types, but convention wisdom seems to be that it's generally > easier > to just store the images as conventional files, and put the filesystem > paths to those files in as regular character data in the database. So > for > example instead of storing a jpg photo, save as /var/foo/images/bar.jpg > and keep that text in whatever database table. I have heard one convincing argument for not doing so, and that is when you need to maintain strict user-based permissions on the images (for whatever reason), and you don't want to code this security into the application nor do you have/want to provide system-level accounts for users. (That is, you provide users with MySQL-level accounts and control the permissions from the database.) > This arguably takes a little more overhead to set up -- purists would > argue that it's wrong to keep data external to the database -- but once > you get it set up this should generally be easier to manage. Maybe, but I disagree with the purists. Imagine if we put binary data in our HTML pages? It's much easier and generally just as effective IMO to use the pathname trick you suggest. To the OP: if you need to make these database-stored images available to web pages (HTML) as the "src" of <img> tags, just write a mini-Perl script to retrieve the data and use the URL to said script as the "src". Just remember to properly MIME-encode the data before echoing it from the mini-Perl script. Erik -- Erik Price (zombies roam) email: [EMAIL PROTECTED] jabber: [EMAIL PROTECTED]
