I'm not sure of the code exactly but I do know it is possible.
in order to save them in a database, just save the filenames, paths also if you want that to, into an array, then once you are done uploading files, add the names to the database that you wish. one insert statement containing both names.
as for the renaming part, you can assume that all file extensions are 3 characters long, and since you know where the files are being saved to, you can call the rename() function(
http://ca3.php.net/manual/en/function.rename.php) to rename it as you wish.
hope this helps you get started.