What is the purpose of the "move_uploaded_file" function in PHP upload scripts?

The "move_uploaded_file" function in PHP upload scripts is used to move an uploaded file to a new location on the server. This function helps to securely store uploaded files in a designated directory, preventing any potential security risks associated with allowing files to be stored in temporary locations.

<?php
$uploadDir = 'uploads/';
$uploadFile = $uploadDir . basename($_FILES['file']['name']);

if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadFile)) {
    echo "File is valid, and was successfully uploaded.";
} else {
    echo "Upload failed";
}
?>