You are here

protected function elFinderVolumeDrupal::FileValidate in elFinder file manager 7.2

Same name and namespace in other branches
  1. 7.3 inc/elfinder.drupalfs.driver.inc \elFinderVolumeDrupal::FileValidate()

Let other Drupal modules perform validation on the uploaded file. See hook_file_validate().

Parameters

string $name file name:

Return value

bool

1 call to elFinderVolumeDrupal::FileValidate()
elFinderVolumeDrupal::_save in inc/elfinder.drupalfs.driver.inc
Create new file and write into it from file pointer. Return new file path or false on error.

File

inc/elfinder.drupalfs.driver.inc, line 350
elFinder driver for Drupal filesystem.

Class

elFinderVolumeDrupal
@file

Code

protected function FileValidate($name) {

  // The uploaded file is still in temp. Fetch it's name & path from $_FILES.
  $index = array_search($name, $_FILES['upload']['name']);
  if ($index !== FALSE) {
    $file = $this
      ->_drupalfileobject($_FILES['upload']['tmp_name'][$index]);
    $validation_errors = module_invoke_all('file_validate', $file);
    if (!empty($validation_errors)) {
      $this
        ->setError(strip_tags(implode(' ', $validation_errors)));
      return FALSE;
    }
  }
  else {
    watchdog('elfinder', 'File upload "' . $name . '" not found in $_FILES');
  }
  return TRUE;
}