Sir please tell me how to import image in database

0 votes
Apr 1, 2020 in Database by Soumadip
• 120 points

reshown Apr 1, 2020 by Sirajul 289 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,720 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
706 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
16,099 views
0 votes
1 answer

How to rename a column in a database table using SQL?

For SQL Server, use sp_rename USE AdventureWorks; GO EXEC sp_rename 'Customers.CustomerTerritory.TerritoryID', ...READ MORE

answered Feb 9 in Database by Neha
• 8,560 points
66 views
0 votes
0 answers

How to change column datatype in SQL database without losing data?

I have a SQL Server database, and ...READ MORE

Feb 25 in Database by Vaani
• 7,020 points
51 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,360 points
1,662 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,830 points
557 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,830 points
947 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,720 points
243 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,720 points
430 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP