diff --git a/core/modules/file/file.module b/core/modules/file/file.module
index 14a4426dd8..c83550ac36 100644
--- a/core/modules/file/file.module
+++ b/core/modules/file/file.module
@@ -932,6 +932,7 @@ function _file_save_upload_single(\SplFileInfo $file_info, $form_field_name, $va
   // 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.
+  $error_to_log = NULL;
   switch ($file_info->getError()) {
     case UPLOAD_ERR_INI_SIZE:
     case UPLOAD_ERR_FORM_SIZE:
@@ -943,6 +944,18 @@ function _file_save_upload_single(\SplFileInfo $file_info, $form_field_name, $va
       \Drupal::messenger()->addError(t('The file %file could not be saved because the upload did not complete.', ['%file' => $original_file_name]));
       return FALSE;
 
+    case UPLOAD_ERR_NO_TMP_DIR:
+      $error_to_log = 'The file %file could not be saved because the server is missing a temporary folder.';
+      break;
+
+    case UPLOAD_ERR_CANT_WRITE:
+      $error_to_log = 'The file ' . $file_info->getFilename() .  ' could not be saved because the server is unable to write to disk.';
+      break;
+
+    case UPLOAD_ERR_EXTENSION:
+      $error_to_log = 'The file ' . $file_info->getFilename() .  ' could not be saved because a PHP extension stopped the file upload. PHP does not provide a way to ascertain which extension caused the file upload to stop; examining the list of loaded extensions with phpinfo() may help.';
+      break;
+
     case UPLOAD_ERR_OK:
       // Final check that this is a valid upload, if it isn't, use the
       // default error handler.
@@ -952,9 +965,19 @@ 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' => $original_file_name]));
-      return FALSE;
-
+      $error_to_log = 'The file ' . $file_info->getFilename() .  ' could not be saved. An unknown error has occurred.';
+      break;
+  }
+  if (isset($error_to_log)) {
+    // Use trigger_error() here so that the error will be reported to the
+    // screen depending on the site's error reporting level.
+    trigger_error($error_to_log, E_USER_ERROR);
+    // Unconditionally display an error message to the end user. This is a
+    // generic message since the errors that trigger this represent
+    // server-level problems that end users should not know about (and cannot
+    // fix by attempting the upload again).
+    \Drupal::messenger()->addError(t('The file %file could not be saved. An unknown error has occurred.', ['%file' => $original_file_name]));
+    return FALSE;
   }
 
   // Build a list of allowed extensions.
