src/Viserio/Component/Http/UploadedFile.php
public function moveTo($targetPath): void
    {
        $this->validateActive();

        if ($this->isStringNotEmpty($targetPath) === false) {
            throw new InvalidArgumentException(
                'Invalid path provided for move operation; must be a non-empty string.'
            );
        }

        if ($this->file) {
            ($this->moved = \in_array(\PHP_SAPI, ['cli', 'phpdbg'], true))
                ? \rename($this->file, $targetPath)
                : \move_uploaded_file($this->file, $targetPath);
        } else {
            Util::copyToStream(
                $this->getStream(),
                new LazyOpenStream($targetPath, 'w')
            );

            $this->moved = true;
        }

        if ($this->moved === false) {
            throw new RuntimeException(
                \sprintf('Uploaded file could not be moved to %s', $targetPath)
            );
        }
    }
public function moveTo($targetPath): void
    {
        $this->validateActive();

        if ($this->isStringNotEmpty($targetPath) === false) {
            throw new InvalidArgumentException(
                'Invalid path provided for move operation; must be a non-empty string.'
            );
        }

        if ($this->file) {
            ($this->moved = \in_array(\PHP_SAPI, ['cli', 'phpdbg'], true))
                ? \rename($this->file, $targetPath)
                : \move_uploaded_file($this->file, $targetPath);
        } else {
            Util::copyToStream(
                $this->getStream(),
                new LazyOpenStream($targetPath, 'w')
            );

            $this->moved = true;
        }

        if ($this->moved === false) {
            throw new RuntimeException(
                \sprintf('Uploaded file could not be moved to %s', $targetPath)
            );
        }
    }
{@inheritdoc}

@see http://php.net/is_uploaded_file
@see http://php.net/move_uploaded_file

@param string $targetPath path to which to move the uploaded file

@throws \Viserio\Component\Contract\Http\Exception\InvalidArgumentException if the $path specified is invalid
@throws \Viserio\Component\Contract\Http\Exception\RuntimeException         if the upload was not successful or on any error during the move operation, or on
the second or subsequent call to the method