上传时重命名多个文件

I have a form that uploads multiple file. The php code that I am using works fine but I would like to rename the files also and don't know how to go about this. I think adding a time stamp to the name would be the best answer. Here is the working code so far:

/* FILE UPLOAD CODE */
{
    $number_of_file_fields = 0;
    $number_of_uploaded_files = 0;
    $number_of_moved_files = 0;
    $uploaded_files = array();
    $upload_directory = dirname(__file__) . '/uploads/'; //set upload directory
    /**
     * we get a $_FILES['file'] array ,
     * we procee this array while iterating with simple for loop
     * you can check this array by print_r($_FILES['file']);
     */
    for ($i = 0; $i < count($_FILES['file']['name']); $i++) {
        $number_of_file_fields++;
        if ($_FILES['file']['name'][$i] != '') { //check if file field empty or not
            $number_of_uploaded_files++;
            $uploaded_files[] = $_FILES['file']['name'][$i];
            if (move_uploaded_file($_FILES['file']['tmp_name'][$i], $upload_directory . $_FILES['file']['name'][$i])) {
                $number_of_moved_files++;
            }

        }

    }

}
/* END FILE UPLOAD CODE */

Any help on what to add and where to accomplish this would be greatly appreciated.

If you want to give the same name to all the uploaded files, then you can get the name by using $_GET. For example:

<form action="upload.php" method="post"> \\ this would send it to your page
<input type='text' size='30' name='filename'/>
<input type='submit' /> 
</form>

simply get the name using $_GET like this

$name = $_GET['filename'];

and now run your code but move the file with this name like this

move_uploaded_file($_FILES['file']['tmp_name'][$i], $upload_directory .         $name[$i])

You can specify the new file name as the second parameter in move_uploaded_file()

For example:

move_uploaded_file($_FILES['file']['tmp_name'][$i], $upload_directory . "new_file_name");