Here's an image upload function I use in PHP 4:
$filename = $HTTP_POST_FILES['pic']['tmp_name'];
if (is_uploaded_file($filename)) {
$save_loc = "/path/to/save/image/to/$filename_new";
// If the file exists, remove the old one
if (file_exists($save_loc)) {
unlink($save_loc);
}
// Move the Uploaded file to the correct Directory
move_uploaded_file ($filename, "$save_loc");
chmod($save_loc, 0755);
}
Then you would insert $HTTP_POST_FILES['pic']['name'] into the database. 'pic' is the name of the file upload field. Go to php.net and search for file upload to read about $HTTP_POST_FILES