42

I need to store image and resume of user in the data base.

I am using mysql data base and php5. I need to know which data types I should use.

And also how do I set a limit (maximum size) for uploaded data.

3
  • i just want to know that which data type support the image files in mysql database. i much familiar with varchar,date , timestamp etc . if u have any idea plz suggest me.
    – rajson
    Commented Mar 19, 2010 at 6:30
  • Common guys, he's very obviously not a native speaker. I've tried to refactor the question. @rasjon: please verify I didn't change the intended meaning.
    – lexu
    Commented Mar 19, 2010 at 7:20
  • There are many, many related or even duplicate questions about this, stackoverflow.com/search?q=storing+images+in+mysql
    – Kimvais
    Commented Mar 19, 2010 at 7:22

3 Answers 3

34

What you need, according to your comments, is a 'BLOB' (Binary Large OBject) for both image and resume.

0
9

Perfect answer for your question can be found on MYSQL site itself.refer their manual(without using PHP)

http://forums.mysql.com/read.php?20,17671,27914

According to them use LONGBLOB datatype. with that you can only store images less than 1MB only by default,although it can be changed by editing server config file.i would also recommend using MySQL workBench for ease of database management

2
  • 1
    won't longblob slow down searching for something?
    – i am me
    Commented Dec 11, 2015 at 18:33
  • 1
    @iamme not unless you're querying against the column that's a longblob. If you have the columns, ("image_name" varchar, "image_data" longblob) for example, and you query image_name, then no, it won't be any slower. Commented Oct 5, 2018 at 18:12
4

This can be done from the command line. This will create a column for your image with a NOT NULL property.

CREATE TABLE `test`.`pic` (
`idpic` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`caption` VARCHAR(45) NOT NULL,
`img` LONGBLOB NOT NULL,
PRIMARY KEY(`idpic`)
)
TYPE = InnoDB; 

From here

Not the answer you're looking for? Browse other questions tagged or ask your own question.