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

Breadcrumb

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

function File::move

Moves the file to a new location.

Throws

FileException if the target file could not be created

2 calls to File::move()
UploadedFile::move in vendor/symfony/http-foundation/File/UploadedFile.php
Moves the file to a new location.
UploadedFile::move in vendor/symfony/http-foundation/File/UploadedFile.php
Moves the file to a new location.
1 method overrides File::move()
UploadedFile::move in vendor/symfony/http-foundation/File/UploadedFile.php
Moves the file to a new location.

File

vendor/symfony/http-foundation/File/File.php, line 85

Class

File
A file in the file system.

Namespace

Symfony\Component\HttpFoundation\File

Code

public function move(string $directory, ?string $name = null) : self {
    $target = $this->getTargetFile($directory, $name);
    set_error_handler(function ($type, $msg) use (&$error) {
        $error = $msg;
    });
    try {
        $renamed = rename($this->getPathname(), $target);
    } finally {
        restore_error_handler();
    }
    if (!$renamed) {
        throw new FileException(\sprintf('Could not move the file "%s" to "%s" (%s).', $this->getPathname(), $target, strip_tags($error)));
    }
    @chmod($target, 0666 & ~umask());
    return $target;
}

API Navigation

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