How to save image using PHP MySQL

April 20, 2009

Posted by: leoslab

Category: PHP

Tags: ,

How to save image using PHP MySQL

I have very simple way to store image in mysql databases. I will describe how to save images in MySQL and display it using PHP.

The first step, we need to make a MySQL databases to store our images data. Make a database called “images” on your MySQL  database, then create a table called “imagesdata”.

CREATE TABLE `imagesdata` (
`id` int(6) NOT NULL AUTO_INCREMENT,
`image` longtext NOT NULL,
`dates` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;