Issue #3156949 by ytsurk, Berdir: Filename is not shown in the maximum allowed...
Issue #3156949 by ytsurk, Berdir: Filename is not shown in the maximum allowed file size error message (w/o using the file_validate_size upload validator)
(cherry picked from commit 70892a69)
// Check for file upload errors and return FALSE for this file if a lower
// level system error occurred. For a complete list of errors:
// See http://php.net/manual/features.file-upload.errors.php.
switch($file_info->getError()){
caseUPLOAD_ERR_INI_SIZE:
caseUPLOAD_ERR_FORM_SIZE:
\Drupal::messenger()->addError(t('The file %file could not be saved because it exceeds %maxsize, the maximum allowed size for uploads.',['%file'=>$file_info->getFilename(),'%maxsize'=>format_size(Environment::getUploadMaxSize())]));
\Drupal::messenger()->addError(t('The file %file could not be saved because it exceeds %maxsize, the maximum allowed size for uploads.',['%file'=>$original_file_name,'%maxsize'=>format_size(Environment::getUploadMaxSize())]));
returnFALSE;
caseUPLOAD_ERR_PARTIAL:
caseUPLOAD_ERR_NO_FILE:
\Drupal::messenger()->addError(t('The file %file could not be saved because the upload did not complete.',['%file'=>$file_info->getFilename()]));
\Drupal::messenger()->addError(t('The file %file could not be saved because the upload did not complete.',['%file'=>$original_file_name]));
returnFALSE;
caseUPLOAD_ERR_OK:
...
...
@@ -933,7 +934,7 @@ function _file_save_upload_single(\SplFileInfo $file_info, $form_field_name, $va
default:
// Unknown error
\Drupal::messenger()->addError(t('The file %file could not be saved. An unknown error has occurred.',['%file'=>$file_info->getFilename()]));
\Drupal::messenger()->addError(t('The file %file could not be saved. An unknown error has occurred.',['%file'=>$original_file_name]));
returnFALSE;
}
...
...
@@ -941,7 +942,7 @@ function _file_save_upload_single(\SplFileInfo $file_info, $form_field_name, $va
$expected_message=newTranslatableMarkup('The file %file could not be saved because it exceeds %maxsize, the maximum allowed size for uploads.',['%file'=>$file_name,'%maxsize'=>format_size(Environment::getUploadMaxSize())]);