In this tutorial, I am going to explain the process of how to Upload image in PHP MySQL Database and display that image from the database and store it in the project folder.
First of all, we have to create a table in the database and then we can insert the image in that particular table in the database.
After inserting the image into the database, it will be moved to the public folder as well so that we can retrieve the image later on.
Also Read, CRUD Operation in PHP using ajax jquery
Here I am using a table ‘image’ with fields like name, age, and image.
DDL information of the table:-
CREATE TABLE `image` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(225) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`age` varchar(225) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`image` varchar(225) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
Complete Code to Upload Image in PHP MySQL Database and display
Download the bootstrap CSS and js files from google and include the path of the files in the href attribute of the link tag and src attribute of the script tag respectively.
CONCLUSION:- I hope this article will help you to upload images in PHP and store it in the database and folder. If you have any doubt then please leave your comment below.