src/Bundle/Common/File/File.php
public function move(string $directory, string $name = ''): File
    {
        $target = $this->getTargetFile($directory, $name);

        if (!@rename($this->getPathname(), $target)) {
            $error = error_get_last();
            throw new FileException(sprintf('Could not rename the file "%s" (%s)', $this->getPathname(), strip_tags($error['message'])));
        }

        $this->customChmod($target);

        return $target;
    }
public function move(string $directory, string $name = ''): File
    {
        $target = $this->getTargetFile($directory, $name);

        if (!@rename($this->getPathname(), $target)) {
            $error = error_get_last();
            throw new FileException(sprintf('Could not rename the file "%s" (%s)', $this->getPathname(), strip_tags($error['message'])));
        }

        $this->customChmod($target);

        return $target;
    }
Moves the file to a new location.

@param string $directory   Destination folder
@param string $name   New file name
@return File
@throws FileException