function file_destination
Same name in other branches
- 7.x includes/file.inc \file_destination()
Determines the destination path for a file.
Parameters
$destination: A string specifying the desired final URI or filepath.
$replace: Replace behavior when the destination file already exists.
- FILE_EXISTS_REPLACE - Replace the existing file.
- FILE_EXISTS_RENAME - Append _{incrementing number} until the filename is unique.
- FILE_EXISTS_ERROR - Do nothing and return FALSE.
Return value
The destination filepath, or FALSE if the file already exists and FILE_EXISTS_ERROR is specified.
Deprecated
in drupal:8.7.0 and is removed from drupal:9.0.0. Use \Drupal\Core\File\FileSystemInterface::getDestinationFilename().
See also
https://www.drupal.org/node/3006851
Related topics
2 calls to file_destination()
- FileSystemDeprecationTest::testDeprecatedFileDestination in core/
tests/ Drupal/ KernelTests/ Core/ File/ FileSystemDeprecationTest.php - @expectedDeprecation file_destination() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\File\FileSystemInterface::getDestinationFilename(). See https://www.drupal.org/node/3006851.
- file_unmanaged_prepare in core/
includes/ file.inc - Internal function that prepares the destination for a file_unmanaged_copy or file_unmanaged_move operation.
File
-
core/
includes/ file.inc, line 588
Code
function file_destination($destination, $replace) {
@trigger_error('file_destination() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \\Drupal\\Core\\File\\FileSystemInterface::getDestinationFilename(). See https://www.drupal.org/node/3006851.', E_USER_DEPRECATED);
return \Drupal::service('file_system')->getDestinationFilename($destination, $replace);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.