Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. UploadedFile.php

function UploadedFile::moveTo

Overrides UploadedFileInterface::moveTo

File

vendor/guzzlehttp/psr7/src/UploadedFile.php, line 162

Class

UploadedFile

Namespace

GuzzleHttp\Psr7

Code

public function moveTo($targetPath) : void {
    $this->validateActive();
    if (false === self::isStringNotEmpty($targetPath)) {
        throw new InvalidArgumentException('Invalid path provided for move operation; must be a non-empty string');
    }
    if ($this->file) {
        $this->moved = PHP_SAPI === 'cli' ? rename($this->file, $targetPath) : move_uploaded_file($this->file, $targetPath);
    }
    else {
        Utils::copyToStream($this->getStream(), new LazyOpenStream($targetPath, 'w'));
        $this->moved = true;
    }
    if (false === $this->moved) {
        throw new RuntimeException(sprintf('Uploaded file could not be moved to %s', $targetPath));
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal