PHP Example
Screen shot
PHP Script to upload image to the server and store into databse(save file as index.php)

<?php
$conn=mysql_connect('localhost','root','') or die('Not connected');
$database=mysql_select_db('test',$conn) or die('Database Not connected');

if(isset($_POST['submit']))
{
if(($_FILES["image_name"]["type"] == "image/gif") || ($_FILES["image_name"]["type"] == "image/jpeg"))
{
$image_name=time().$_FILES["image_name"]["name"];
move_uploaded_file($_FILES["image_name"]["tmp_name"],"upload/".$image_name);
$query="insert into images set image_name='$image_name'";
mysql_query($query);
}
else
echo "You can upload only gif and jpeg file";
}
?>
<html>
<body>
<form action="" method="post" enctype="multipart/form-data">
Select image:<input type="file" name="image_name" id="image_name" /><br />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>

Mysql Database

--
-- Database: `test`
--

-- --------------------------------------------------------

--
-- Table structure for table `images`
--

CREATE TABLE IF NOT EXISTS `images` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `image_name` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;

--
-- Dumping data for table `images`
--

INSERT INTO `images` (`id`, `image_name`) VALUES
(1, '1326847316img1.jpg'),
(2, '1326847323img2.jpg'),
(3, '1326848764img4.jpg');

You can download source code here