function FileUploadResource::prepareFilename
Same name in other branches
- 8.9.x core/modules/file/src/Plugin/rest/resource/FileUploadResource.php \Drupal\file\Plugin\rest\resource\FileUploadResource::prepareFilename()
- 10 core/modules/file/src/Plugin/rest/resource/FileUploadResource.php \Drupal\file\Plugin\rest\resource\FileUploadResource::prepareFilename()
Prepares the filename to strip out any malicious extensions.
Parameters
string $filename: The file name.
array $validators: The array of upload validators.
Return value
string The prepared/munged filename.
1 call to FileUploadResource::prepareFilename()
- FileUploadResource::post in core/
modules/ file/ src/ Plugin/ rest/ resource/ FileUploadResource.php - Creates a file from an endpoint.
File
-
core/
modules/ file/ src/ Plugin/ rest/ resource/ FileUploadResource.php, line 508
Class
- FileUploadResource
- File upload resource.
Namespace
Drupal\file\Plugin\rest\resourceCode
protected function prepareFilename($filename, array &$validators) {
// The actual extension validation occurs in
// \Drupal\file\Plugin\rest\resource\FileUploadResource::validate().
$extensions = $validators['file_validate_extensions'][0] ?? '';
$event = new FileUploadSanitizeNameEvent($filename, $extensions);
$this->eventDispatcher
->dispatch($event);
return $event->getFilename();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.