file_move

function file_move

file_move(FileInterface $source, $destination = NULL, $replace = FILE_EXISTS_RENAME)

Moves a file to a new location and update the file's database entry.

  • Checks if $source and $destination are valid and readable/writable.
  • Performs a file move if $source is not equal to $destination.
  • If file already exists in $destination either the call will error out, replace the file or rename the file based on the $replace parameter.
  • Adds the new file to the files database.

Parameters

\Drupal\file\FileInterface $source: A file entity.

string $destination: A