file_destination($destination, $replace)
Determines the destination path for a file.
$destination: A string specifying the desired final URI or filepath.
$replace: Replace behavior when the destination file already exists.
The destination filepath, or FALSE if the file already exists and FILE_EXISTS_ERROR is specified.
function file_destination($destination, $replace) { if (file_exists($destination)) { switch ($replace) { case FILE_EXISTS_REPLACE: // Do nothing here, we want to overwrite the existing file. break; case FILE_EXISTS_RENAME: $basename = drupal_basename($destination); $directory = drupal_dirname($destination); $destination = file_create_filename($basename, $directory); break; case FILE_EXISTS_ERROR: // Error reporting handled by calling function. return FALSE; } } return $destination; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!includes!file.inc/function/file_destination/8.1.x