What are the necessary server requirements for uploading a file via PHP script?

When uploading a file via a PHP script, the server must have the following requirements: 1. Sufficient upload_max_filesize and post_max_size limits set in php.ini to allow for larger file uploads. 2. Proper permissions set on the upload directory to allow PHP to write files. 3. The file_uploads directive in php.ini must be set to On to enable file uploads.

<?php
// Check if file was uploaded successfully
if ($_FILES['file']['error'] === UPLOAD_ERR_OK) {
    $uploadDir = 'uploads/';
    $uploadFile = $uploadDir . basename($_FILES['file']['name']);

    // Move uploaded file to specified directory
    if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadFile)) {
        echo "File uploaded successfully.";
    } else {
        echo "File upload failed.";
    }
} else {
    echo "Error uploading file.";
}
?>