Here is the form
<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="file"/>
<br />
<input type="submit"/>
</form>
and Here is the script
<?php
$hostname = "hostname";
$db_user = "username";
$db_password = "passwrd";
$database = "db";
$db_table = "dbtable";
$db = mysql_connect($hostname, $db_user, $db_password);
mysql_select_db($database,$db);
$uploadDir = 'listings/';
if(isset($_POST['submit']))
{
$fileName = $_FILES['Photo']['name'];
$tmpName = $_FILES['Photo']['tmp_name'];
$fileSize = $_FILES['Photo']['size'];
$fileType = $_FILES['Photo']['type'];
$filePath = $uploadDir . $fileName;
$result = move_uploaded_file($tmpName, $filePath);
if (!$result) {
echo "Error uploading file";
exit;
}
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}
$query = "UPDATE $db_table SET `image_name` = '$fileName' WHERE `id` = 1";
mysql_query($query) or die('Error, query failed');
}
?>