+/**
+ * Saves a file upload to a new location.
+ *
+ * @param \SplFileInfo $file_info
+ * The file upload to save.
+ * @param string $form_field_name
+ * A string that is the associative array key of the upload form element in
+ * the form array.
+ * @param array $validators
+ * (optional) An associative array of callback functions used to validate the
+ * file.
+ * @param bool $destination
+ * (optional) A string containing the URI that the file should be copied to.
+ * @param int $replace
+ * (optional) The replace behavior when the destination file already exists.
+ *
+ * @return \Drupal\file\FileInterface|false
+ * The created file entity or FALSE if the uploaded file not saved.
+ *
+ * @throws \Drupal\Core\Entity\EntityStorageException
+ *
+ * @internal
+ * This method should only be called from file_save_upload(). Use that method
+ * instead.
+ *
+ * @see file_save_upload()
+ */
+function _file_save_upload_single(\SplFileInfo $file_info, $form_field_name, $validators = [], $destination = FALSE, $replace = FILE_EXISTS_RENAME) {
+ $user = \Drupal::currentUser();
+ // 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()) {
+ case UPLOAD_ERR_INI_SIZE:
+ case UPLOAD_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(file_upload_max_size())]));
+ return FALSE;
+
+ case UPLOAD_ERR_PARTIAL:
+ case UPLOAD_ERR_NO_FILE:
+ \Drupal::messenger()->addError(t('The file %file could not be saved because the upload did not complete.', ['%file' => $file_info->getFilename()]));
+ return FALSE;