Different upload file size limits based on file type

You can try to use the next code:

// NAV: Different upload file size limits based on file type
function wpcoder_upload_files_limits($file) {
    // Define custom file size limits based on file type
    $file_size_limits = array(
        'mp4' => 64 * 1024 * 1024, // 64 MB
        'pdf' => 30 * 1024 * 1024, // 30 MB
        'png' => 15 * 1024 * 1024, // 15 MB
        'jpeg' => 15 * 1024 * 1024, // 15 MB
        'doc' => 25 * 1024 * 1024, // 25 MB
        'xls' => 25 * 1024 * 1024, // 25 MB
        'ppt' => 25 * 1024 * 1024, // 25 MB
    );

    $file_ext = pathinfo($file['name'], PATHINFO_EXTENSION);
    
    // Check if the file type has a custom size limit
    if (isset($file_size_limits[$file_ext])) {
        $max_file_size = $file_size_limits[$file_ext];
        
        // Check if the uploaded file exceeds the custom size limit
        if ($file['size'] > $max_file_size) {
            $file['error'] = 'File size exceeds the allowed limit for ' . esc_attr($file_size_limits[$file_ext]). 'KB ' . esc_attr(strtoupper($file_ext));
        }
    }

    return $file;
}

add_filter('wp_handle_upload_prefilter', 'wpcoder_upload_files_limits');

You can insert this code in the footer.php or use the free plugin WP Coder and insert this code in ‘Global PHP’

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)