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

Breadcrumb

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

function FileUploadHandler::moveUploadedFile

Move the uploaded file from the temporary path to the destination.

Parameters

\Drupal\file\Upload\UploadedFileInterface $uploadedFile: The uploaded file.

string $uri: The destination URI.

Return value

bool Returns FALSE if moving failed.

See also

https://www.drupal.org/project/drupal/issues/2940383

1 call to FileUploadHandler::moveUploadedFile()
FileUploadHandler::handleFileUpload in core/modules/file/src/Upload/FileUploadHandler.php
Creates a file from an upload.

File

core/modules/file/src/Upload/FileUploadHandler.php, line 295

Class

FileUploadHandler
Handles validating and creating file entities from file uploads.

Namespace

Drupal\file\Upload

Code

protected function moveUploadedFile(UploadedFileInterface $uploadedFile, string $uri) : bool {
    if ($uploadedFile instanceof FormUploadedFile) {
        return $this->fileSystem
            ->moveUploadedFile($uploadedFile->getRealPath(), $uri);
    }
    // We use FileExists::Error) as the file location has already
    // been determined above in FileSystem::getDestinationFilename().
    return $this->fileSystem
        ->move($uploadedFile->getRealPath(), $uri, FileExists::Error);
}

API Navigation

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