December 16th, 2003, 02:33 PM
Store and retrieve images in SQL
I need to create a form that will allow the user to browse for an image to upload.
The image needs to be stored in an inmage datatype in SQL (MS SQL).
Then I need to be able to select the image to be viewed later.
I use cold fusion all the time, but I've never stored an image or any kind of binary in the DB, so I have no idea how to do it.
I'm trying to just manually store an image in my table right now, so I can see if I can display it. Any tips there would be helpful there too.
Any help would be greatly appreciated. Thanks in advance.
December 16th, 2003, 03:54 PM
I found a better way to do it. Thanks.
I guess the better question now is, how do I delete this post?
December 16th, 2003, 08:30 PM
I believe that you could do this as a BLOB. But a much easier way to do it is to store the image in your file system somewhere, and then store the *path* to the image in the database.
December 17th, 2003, 07:34 AM
You're right. After making my second post last night I realized it would be nice if I told everyone what I had figured out.
After finding posts about this subject on other forums, 100% suggested NOT to put it in the DB and keep it on the file system instead.
So that's what I'm doing. There is one image per record, so when the user uploads the file, I change the name to be the same as the record_id. So if the record_id is 35, the image is changed to 35.jpg.