function FileUploadHandler::moveUploadedFile
Same name in other branches
- 9 core/modules/file/src/Upload/FileUploadHandler.php \Drupal\file\Upload\FileUploadHandler::moveUploadedFile()
- 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.
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 389
Class
- FileUploadHandler
- Handles validating and creating file entities from file uploads.
Namespace
Drupal\file\UploadCode
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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.