Sir please tell me how to import image in database?

0 votes
Mar 31 in Database by Soumadip
• 120 points

reshown Apr 1 by Sirajul 67 views

1 answer to this question.

0 votes

Hello soumadip,

(Assuming you are using mysql database)

You will  able to get it done by moving the image(fileName.jpg) file first in to below folder(in my case) C:\ProgramData\MySQL\MySQL Server 7.2\Uploads and then I executed below command and it works for me,

INSERT INTO Niraj(ID,IMAGE) VALUES(1,LOAD_FILE('C:/ProgramData/MySQL/MySQL Server 7.2/Uploads/fileName.jpg'));

Here assuming the images is on my local computer, in the images folder:

//Create the table
 CREATE TABLE images (
        picid int NOT NULL AUTO_INCREMENT,
        description VARCHAR(40),
        image BLOB,
        PRIMARY KEY (picid));

// Insert the row
INSERT INTO images VALUES
        (NULL,'picture of a frog','c\:images\frog.png');

Hope this helps.

Thank you!!

answered Apr 1 by Niroj
• 22,110 points

Related Questions In Database

0 votes
2 answers
0 votes
1 answer

How to load data of .csv file in MySQL Database Table?

At first, put the dataset in the ...READ MORE

answered Jul 5, 2019 in Database by Reshma
352 views
0 votes
2 answers

How to select the nth row in a SQL database table?

SELECT * FROM ( SELECT ID, NAME, ROW_NUMBER() ...READ MORE

answered Apr 23 in Database by anand
• 140 points
1,407 views
0 votes
1 answer

How to do a batch insert in MySQL

You can try out the following query: INSERT ...READ MORE

answered Sep 10, 2018 in Database by Sahiti
• 6,290 points
827 views
0 votes
1 answer

How to connect to MySQL Database?

using MySql.Data; using MySql.Data.MySqlClient; namespace Data { ...READ MORE

answered Oct 12, 2018 in Database by Frankie
• 9,810 points
215 views
0 votes
1 answer

How to cache data in a MVC application?

Reference the System.Web dll in your model ...READ MORE

answered Oct 25, 2018 in Database by Frankie
• 9,810 points
473 views
0 votes
1 answer

How to install MySQL in windows?

You can download the all in one ...READ MORE

answered Feb 27, 2019 in Database by Priyaj
• 57,530 points
99 views
0 votes
1 answer

How to install MySQL in Ubuntu?

To install MySQL on ubuntu you have ...READ MORE

answered Feb 28, 2019 in Database by Priyaj
• 57,530 points
188 views
0 votes
1 answer

How to empty a redis database?

Hello @kartik, You have two options: FLUSHDB - clears currently ...READ MORE

answered May 4 in Database by Niroj
• 22,110 points
19 views
0 votes
1 answer

How to take MySQL database backup using MySQL Workbench?

Hii, You can export like this: Hope this is ...READ MORE

answered May 4 in Database by Niroj
• 22,110 points
25 views