diff -u b/core/modules/file/file.module b/core/modules/file/file.module --- b/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -702,10 +702,11 @@ */ function file_save_upload_from_form($element, FormStateInterface $form_state, $delta = NULL, $replace = FILE_EXISTS_RENAME) { $destination = isset($element['#upload_location']) ? $element['#upload_location'] : FALSE; + $validators = isset($element['#upload_validators']) ? $element['#upload_validators'] : array(); $upload_name = implode('_', $element['#parents']); $errors_before = drupal_get_messages('error'); - $files = file_save_upload($upload_name, $element['#upload_validators'], $destination, $delta, $replace); + $files = file_save_upload($upload_name, $validators, $destination, $delta, $replace); // Get all possible new errors that are generated while trying to save the // upload. @@ -835,7 +836,7 @@ break; } - // Unknown error + // Unknown error default: drupal_set_message(t('The file %file could not be saved. An unknown error has occurred.', array('%file' => $file_info->getFilename())), 'error'); $files[$i] = FALSE; @@ -1279,7 +1280,6 @@ return array(); } - /** * Prepares variables for file form widget templates. * diff -u b/core/modules/system/src/Form/ThemeSettingsForm.php b/core/modules/system/src/Form/ThemeSettingsForm.php --- b/core/modules/system/src/Form/ThemeSettingsForm.php +++ b/core/modules/system/src/Form/ThemeSettingsForm.php @@ -357,9 +357,10 @@ if ($this->moduleHandler->moduleExists('file')) { // Handle file uploads. $validators = array('file_validate_is_image' => array()); + $logo_upload_element = $form['logo']['settings']['logo_upload']; // Check for a new uploaded logo. - $file = file_save_upload_from_form($form['logo_upload'], $form_state, 0); + $file = file_save_upload_from_form($logo_upload_element, $form_state, 0); if (isset($file)) { // File upload was attempted. if ($file) { @@ -368,14 +369,14 @@ } else { // File upload failed. - $form_state->setErrorByName('logo_upload', $this->t('The logo could not be uploaded.')); + $form_state->setErrorByName($logo_upload_element, $this->t('The logo could not be uploaded.')); } } $validators = array('file_validate_extensions' => array('ico png gif jpg jpeg apng svg')); // Check for a new uploaded favicon. - $file = file_save_upload_from_form($form['favicon_upload'], $form_state, 0); + $file = file_save_upload_from_form($form['favicon']['settings']['favicon_upload'], $form_state, 0); if (isset($file)) { // File upload was attempted. if ($file) {