You are here

public static function Upload::validateFileName in IMCE 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/ImcePlugin/Upload.php \Drupal\imce\Plugin\ImcePlugin\Upload::validateFileName()

Validates the name of a file object.

File

src/Plugin/ImcePlugin/Upload.php, line 86

Class

Upload
Defines Imce Upload plugin.

Namespace

Drupal\imce\Plugin\ImcePlugin

Code

public static function validateFileName(FileInterface $file, ImceFM $fm) {
  $errors = [];
  $filename = $file
    ->getFileName();
  if (!$fm
    ->validateFileName($filename, TRUE)) {
    $errors[] = t('%filename contains invalid characters.', [
      '%filename' => $filename,
    ]);
  }
  return $errors;
}