The legacy file_validate_size() function and its corresponding file_validate_size plugin have been completely removed in Drupal 11.To restrict file upload sizes in Drupal 11, you must use the updated Form API structure with the FileSize constraint plugin.

Comments

shivenduray created an issue. See original summary.

shivenduray’s picture

Legacy Syntax (Broken in Drupal 11)

$validators = ['file_validate_extensions' => ['pdf docx']];
$file = file_save_upload('form_field_name', $validators);

Drupal 11 Syntax (Correct)
$validators = [
'FileExtension' => [
'extensions' => 'pdf docx',
],
];
$file = file_save_upload('form_field_name', $validators);

shivenduray’s picture

Patch for resolve Issue with upload validators

  • 0844f16f committed on 11.0.1.x
    Issue #3606988...