public function DropzoneJsUploadSave::validateFile in DropzoneJS 8
Same name and namespace in other branches
- 8.2 src/DropzoneJsUploadSave.php \Drupal\dropzonejs\DropzoneJsUploadSave::validateFile()
Validate the uploaded file.
Parameters
\Drupal\file\FileInterface $file: The file entity object.
string $extensions: A space separated string of valid extensions.
array $additional_validators: An optional, associative array of callback functions used to validate the file. See file_validate() for more documentation. Note that we add file_validate_extensions and file_validate_name_length in this method already.
Return value
array An array containing validation error messages.
Overrides DropzoneJsUploadSaveInterface::validateFile
1 call to DropzoneJsUploadSave::validateFile()
- DropzoneJsUploadSave::createFile in src/
DropzoneJsUploadSave.php - Creates a file entity form an uploaded file.
File
- src/
DropzoneJsUploadSave.php, line 174
Class
- DropzoneJsUploadSave
- A service that saves files uploaded by the dropzonejs element as files.
Namespace
Drupal\dropzonejsCode
public function validateFile(FileInterface $file, $extensions, array $additional_validators = []) {
$validators = $additional_validators;
if (!empty($extensions)) {
$validators['file_validate_extensions'] = [
$extensions,
];
}
$validators['file_validate_name_length'] = [];
// Call the validation functions specified by this function's caller.
return file_validate($file, $validators);
}