Sir please tell me how to import image in database

0 votes
Mar 31, 2020 in Database by Soumadip
• 120 points

reshown Apr 1, 2020 by Sirajul 175 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, 2020 by Niroj
• 82,680 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
519 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, 2020 in Database by anand
• 140 points
8,002 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,380 points
1,317 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
373 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
705 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
• 58,100 points
230 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
• 58,100 points
321 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, 2020 in Database by Niroj
• 82,680 points
126 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, 2020 in Database by Niroj
• 82,680 points
211 views