What are some best practices for error handling and debugging when encountering issues with file uploads in PHP?

When encountering issues with file uploads in PHP, it is important to properly handle errors and debug the code to identify the root cause. One common issue is exceeding the maximum file size allowed by the server configuration, which can be fixed by adjusting the `upload_max_filesize` and `post_max_size` settings in php.ini.

// Increase file upload size limits in php.ini
ini_set('upload_max_filesize', '20M');
ini_set('post_max_size', '25M');
```

Another common issue is incorrect file permissions on the upload directory, which can be resolved by setting the correct permissions using `chmod()` function.

```php
// Set correct permissions on upload directory
chmod('uploads/', 0755);
```

Additionally, it is recommended to validate file types and check for errors during the upload process using `$_FILES['file']['error']` to handle any issues that may arise.

```php
// Validate file type and check for errors during upload
if ($_FILES['file']['error'] !== UPLOAD_ERR_OK) {
    // Handle error
    echo 'Error uploading file';
}