src/Message/Server/UploadedFile.php
public function moveTo($targetPath)
    {
        $this->checkMoved();
        $this->checkTargetDirExists($targetPath);
        $this->checkUpload($targetPath);

        $exception = null;
        set_error_handler(function ($number, $error) use (&$exception) {
            $exception = new RuntimeException(
                "Cannot move uploaded file: ($number) {$error}"
            );
        });

        move_uploaded_file($this->tmpFile, $targetPath);
        restore_error_handler();

        if ($exception instanceof RuntimeException) {
            throw $exception;
        }

        $this->stream = null;
        $this->moved = true;
    }
public function moveTo($targetPath)
    {
        $this->checkMoved();
        $this->checkTargetDirExists($targetPath);
        $this->checkUpload($targetPath);

        $exception = null;
        set_error_handler(function ($number, $error) use (&$exception) {
            $exception = new RuntimeException(
                "Cannot move uploaded file: ($number) {$error}"
            );
        });

        move_uploaded_file($this->tmpFile, $targetPath);
        restore_error_handler();

        if ($exception instanceof RuntimeException) {
            throw $exception;
        }

        $this->stream = null;
        $this->moved = true;
    }
Move the uploaded file to a new location.

$targetPath may be an absolute path, or a relative path. If it is a
relative path, resolution should be the same as used by PHP's rename()
function.

The original file or stream will be removed on completion.

If this method is called more than once, any subsequent calls will raise
an exception.

@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 InvalidArgumentException if the $targetPath specified is invalid.
@throws RuntimeException on any error during the move operation, or on
the second or subsequent call to the method.