How can PHP be used to allow users to upload files to a website?

To allow users to upload files to a website using PHP, you can create a form with an input field of type "file" and set the form's enctype attribute to "multipart/form-data". Then, in the PHP script that processes the form submission, you can use the $_FILES superglobal to access the uploaded file and move it to a desired location on the server.

<form action="upload.php" method="post" enctype="multipart/form-data">
    <input type="file" name="file">
    <input type="submit" value="Upload">
</form>
```

```php
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $file = $_FILES["file"];
    $uploadDir = "uploads/";
    $uploadFile = $uploadDir . basename($file["name"]);

    if (move_uploaded_file($file["tmp_name"], $uploadFile)) {
        echo "File uploaded successfully.";
    } else {
        echo "Error uploading file.";
    }
}
?>