How can a file uploaded with $_FILES be moved in PHP?

To move a file uploaded with $_FILES in PHP, you can use the move_uploaded_file() function. This function takes two parameters: the temporary file location of the uploaded file and the destination where you want to move the file to. By using move_uploaded_file(), you can securely move the uploaded file to a specified directory on the server.

$uploadedFile = $_FILES['file']['tmp_name'];
$destination = 'uploads/' . $_FILES['file']['name'];

if (move_uploaded_file($uploadedFile, $destination)) {
    echo 'File moved successfully.';
} else {
    echo 'Failed to move file.';
}