public function move(string $targetPath, string $name = null, bool $overwrite = false)
	{
		$targetPath  = rtrim($targetPath, '/') . '/';
		$name        = $name ?? $this->getBaseName();
		$destination = $overwrite ? $targetPath . $name : $this->getDestination($targetPath . $name);

		$oldName = empty($this->getRealPath()) ? $this->getPath() : $this->getRealPath();

		if (! @rename($oldName, $destination))
		{
			$error = error_get_last();
			throw FileException::forUnableToMove($this->getBasename(), $targetPath, strip_tags($error['message']));
		}

		@chmod($targetPath, 0777 & ~umask());

		return new File($destination);
	}
public function move(string $targetPath, string $name = null, bool $overwrite = false)
	{
		$targetPath  = rtrim($targetPath, '/') . '/';
		$name        = $name ?? $this->getBaseName();
		$destination = $overwrite ? $targetPath . $name : $this->getDestination($targetPath . $name);

		$oldName = empty($this->getRealPath()) ? $this->getPath() : $this->getRealPath();

		if (! @rename($oldName, $destination))
		{
			$error = error_get_last();
			throw FileException::forUnableToMove($this->getBasename(), $targetPath, strip_tags($error['message']));
		}

		@chmod($targetPath, 0777 & ~umask());

		return new File($destination);
	}
public function move ( string $ targetPath , string $ name = null , bool $ overwrite = false ) { $ targetPath = rtrim ( $ targetPath , '/' ) . '/' ; $ name = $ name ?? $ this -> getBaseName ( ) ; $ destination = $ overwrite ? $ targetPath . $ name : $ this -> getDestination ( $ targetPath . $ name ) ; $ oldName = empty ( $ this -> getRealPath ( ) ) ? $ this -> getPath ( ) : $ this -> getRealPath ( ) ; if ( ! @ rename ( $ oldName , $ destination ) ) { $ error = error_get_last ( ) ; throw FileException :: forUnableToMove ( $ this -> getBasename ( ) , $ targetPath , strip_tags ( $ error [ 'message' ] ) ) ; } @ chmod ( $ targetPath , 0777 & ~ umask ( ) ) ; return new File ( $ destination ) ; }
Moves a file to a new location.

@param string      $targetPath
@param string|null $name
@param boolean     $overwrite

@return \CodeIgniter\Files\File
Moves a file to a new location .