#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Buffalo, NY
    Posts
    156
    Rep Power
    12

    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.
    Forget Milk!
    Gotspy?

    www.gotspy.com
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Buffalo, NY
    Posts
    156
    Rep Power
    12

    Nevermind


    I found a better way to do it. Thanks.

    I guess the better question now is, how do I delete this post?
    Forget Milk!
    Gotspy?

    www.gotspy.com
  4. #3
  5. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,243
    Rep Power
    967
    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.
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Buffalo, NY
    Posts
    156
    Rep Power
    12
    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.
    Forget Milk!
    Gotspy?

    www.gotspy.com

IMN logo majestic logo threadwatch logo seochat tools logo