What is a common issue when trying to implement a simple file upload in PHP?

One common issue when trying to implement a simple file upload in PHP is not setting the correct permissions on the upload directory. To solve this issue, make sure the upload directory has write permissions for the web server user. Additionally, ensure that the HTML form has the correct enctype attribute set to "multipart/form-data" to allow file uploads.

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

    if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadFile)) {
        echo 'File uploaded successfully.';
    } else {
        echo 'Failed to upload file.';
    }
}
?>

<form method="post" enctype="multipart/form-data">
    <input type="file" name="file">
    <input type="submit" value="Upload">
</form>