What are the best practices for handling large file uploads in PHP to avoid memory exhaustion?

When handling large file uploads in PHP, it is important to avoid memory exhaustion by using techniques such as streaming the file directly to disk instead of loading it into memory. One way to achieve this is by utilizing the `move_uploaded_file()` function to move the uploaded file from the temporary directory to a designated location on the server.

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

if (move_uploaded_file($uploadedFile, $targetFile)) {
    echo "File uploaded successfully.";
} else {
    echo "Error uploading file.";
}