function FileSystemInterface::copy

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/File/FileSystemInterface.php \Drupal\Core\File\FileSystemInterface::copy()
  2. 10 core/lib/Drupal/Core/File/FileSystemInterface.php \Drupal\Core\File\FileSystemInterface::copy()
  3. 11.x core/lib/Drupal/Core/File/FileSystemInterface.php \Drupal\Core\File\FileSystemInterface::copy()

Copies a file to a new location without invoking the file API.

This is a powerful function that in many ways performs like an advanced version of copy().

Parameters

string $source: A string specifying the filepath or URI of the source file.

string $destination: A URI containing the destination that $source should be copied to. The URI may be a bare filepath (without a scheme).

int $replace: Replace behavior when the destination file already exists:

Return value

string The path to the new file.

Throws

\Drupal\Core\File\Exception\FileException Implementation may throw FileException or its subtype on failure.

1 method overrides FileSystemInterface::copy()
FileSystem::copy in core/lib/Drupal/Core/File/FileSystem.php
Copies a file to a new location without invoking the file API.

File

core/lib/Drupal/Core/File/FileSystemInterface.php, line 311

Class

FileSystemInterface
Provides an interface for helpers that operate on files and stream wrappers.

Namespace

Drupal\Core\File

Code

public function copy($source, $destination, $replace = self::EXISTS_RENAME);

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