how to insert image in database using php : In some registration or sign up HTML For via php as well as web application i required image upload. For Example: For User Profile picture upload, Your Product gallery photo upload, portfolio image etc.
how to insert image in database using php?
There are Main 2 methods to insert images in mysql database.
Using binary format
In this type I directly simple step by step insert the image in mysql database table using binary format.
Using all the any types of the image upload in single folder
In this type i upload the image in a folder as well as store the image name in MySql database table.
For insert query to image in MySQL first i have to create a table in data base.
CREATE TABLE `portfolio` ( `id` int(11) NOT NULL, `portfolio_img` varchar(55) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
index.php
Insert Image in MySql using PHP - www.pakainfo.com
do_upload.php
Don’t Miss : How To Upload File/Image In CodeIgniter?
CREATE TABLE `portfolio_img` ( `id` int(11) NOT NULL, `portfolio_img` LONGBLOB NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Here we using 1 file for insert portfolio_img in MySQL:
Simple HTML form that allow users to select the portfolio_img file they want to upload.
Using binary format
index.php
Insert Image in MySql using PHP - www.pakainfo.com
I hope you get an idea about how to insert image in database using php.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.