function FileUploadHandler::moveUploadedFile

Same name in other branches
  1. 10 core/modules/file/src/Upload/FileUploadHandler.php \Drupal\file\Upload\FileUploadHandler::moveUploadedFile()
  2. 11.x core/modules/file/src/Upload/FileUploadHandler.php \Drupal\file\Upload\FileUploadHandler::moveUploadedFile()

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

@todo Allows a sub-class to override this method in order to handle raw file uploads in https://www.drupal.org/project/drupal/issues/2940383.

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 289

Class

FileUploadHandler
Handles validating and creating file entities from file uploads.

Namespace

Drupal\file\Upload

Code

protected function moveUploadedFile(UploadedFileInterface $uploadedFile, string $uri) {
    return $this->fileSystem
        ->moveUploadedFile($uploadedFile->getRealPath(), $uri);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.