What could be causing the file upload issue in the PHP script?

The file upload issue in the PHP script could be caused by incorrect file permissions, insufficient server resources, or incorrect file upload settings in the PHP configuration. To solve this issue, you can check and adjust the file permissions, increase server resources if needed, and ensure that the PHP configuration allows file uploads.

<?php
// Increase maximum file size and execution time
ini_set('upload_max_filesize', '20M');
ini_set('post_max_size', '20M');
ini_set('max_execution_time', 300);

// Check if file was uploaded successfully
if ($_FILES['file']['error'] === UPLOAD_ERR_OK) {
    $uploadPath = 'uploads/' . basename($_FILES['file']['name']);
    move_uploaded_file($_FILES['file']['tmp_name'], $uploadPath);
    echo 'File uploaded successfully.';
} else {
    echo 'File upload failed.';
}
?>