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

Breadcrumb

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

function FileSystem::moveUploadedFile

Overrides FileSystemInterface::moveUploadedFile

File

core/lib/Drupal/Core/File/FileSystem.php, line 74

Class

FileSystem
Provides helpers to operate on files and stream wrappers.

Namespace

Drupal\Core\File

Code

public function moveUploadedFile($filename, $uri) {
    $result = @move_uploaded_file($filename, $uri);
    // PHP's move_uploaded_file() does not properly support streams if
    // open_basedir is enabled so if the move failed, try finding a real path
    // and retry the move operation.
    if (!$result) {
        if ($realpath = $this->realpath($uri)) {
            $result = move_uploaded_file($filename, $realpath);
        }
        else {
            $result = move_uploaded_file($filename, $uri);
        }
    }
    return $result;
}
RSS feed
Powered by Drupal