elseif (!
$form_state->
isValueEmpty('extensions'
)) { $validators['file_validate_extensions'
] =
[$form_state->
getValue('extensions'
)];
} // The test for \Drupal::service('file_system')->moveUploadedFile()
// triggering a warning is unavoidable. We're interested in what happens
// afterwards in file_save_upload().
if (\Drupal::
state()->
get('file_test.disable_error_collection'
)) { define('SIMPLETEST_COLLECT_ERRORS', FALSE
);
} $file =
file_save_upload('file_test_upload',
$validators,
$destination, 0,
$form_state->
getValue('file_test_replace'
));
if ($file) { $form_state->
setValue('file_test_upload',
$file);
\Drupal::
messenger()->
addStatus(t('File @filepath was uploaded.',
['@filepath' =>
$file->
getFileUri()]));
\Drupal::
messenger()->
addStatus(t('File name is @filename.',
['@filename' =>
$file->
getFilename()]));
\Drupal::
messenger()->
addStatus(t('File MIME type is @mimetype.',
['@mimetype' =>
$file->
getMimeType()]));
\Drupal::
messenger()->
addStatus(t('You WIN!'
));
} elseif ($file === FALSE
) { \Drupal::
messenger()->
addError(t('Epic upload FAIL!'
));
} }}