First, you should to prepare your database to receive and save the images. On this example, I assume you use MySQL as the database engine. Next time you can use another database than this one, but the logic is still the same. Here is the table structure:
CREATE TABLE image ( image_id int(10) unsigned NOT NULL auto_increment, image_type varchar(50) NOT NULL default '', image longblob NOT NULL, image_size bigint(20) NOT NULL default '0', image_name varchar(255) NOT NULL default '', image_date datetime NOT NULL default '0000-00-00 00:00:00', UNIQUE KEY image_id (image_id) );