What best practices should be followed when configuring PHP upload scripts to handle files of varying sizes efficiently?

When configuring PHP upload scripts to handle files of varying sizes efficiently, it is important to set appropriate values for PHP configuration settings such as `upload_max_filesize`, `post_max_size`, and `memory_limit`. Additionally, it is recommended to use server-side validation to check the file size before processing it, and to handle large file uploads asynchronously to prevent timeouts.

// Set appropriate values for PHP configuration settings
ini_set('upload_max_filesize', '20M');
ini_set('post_max_size', '25M');
ini_set('memory_limit', '128M');

// Server-side validation to check file size before processing
if ($_FILES['file']['size'] > 5242880) {
    die('File size is too large. Please upload a file smaller than 5MB.');
}

// Handle large file uploads asynchronously
set_time_limit(0);
ignore_user_abort(true);

// Process file upload
// Your file upload processing code here