Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Save + store images from database

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hola guys.
I want to develope a web site for book store, and this will contain description about the book and an image.
my question:
What is the data type should MySQL4.0.4 use for images?
What is the data type for the Description field? (Description may be a big one).
How to save and store the image from the data base? :roll:
 
Tim Baker
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you need to save the image into the database as type longblob
I'm not sure about the description one, probably TEXT or LONGTEXT look at the MySQL type docs http://www.mysql.com/doc/en/Column_types.html
to put the image in the database you do something like this:

to get it out you do something like this:

This may not be best solution but this is what I use when I couldn't find any good tutorials on the subject.
[ December 12, 2003: Message edited by: Tim Baker ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic