You are here

public function S3fsFileService::moveUploadedFile in S3 File System 8.3

Same name and namespace in other branches
  1. 4.0.x src/S3fsFileService.php \Drupal\s3fs\S3fsFileService::moveUploadedFile()

Moves an uploaded file to a new location.

PHP's move_uploaded_file() does not properly support streams if open_basedir is enabled, so this function fills that gap.

Compatibility: normal paths and stream wrappers.

Parameters

string $filename: The filename of the uploaded file.

string $uri: A string containing the destination URI of the file.

Return value

bool TRUE on success, or FALSE on failure.

Overrides FileSystemInterface::moveUploadedFile

See also

move_uploaded_file()

https://www.drupal.org/node/515192

File

src/S3fsFileService.php, line 117

Class

S3fsFileService
Provides helpers to operate on files and stream wrappers.

Namespace

Drupal\s3fs

Code

public function moveUploadedFile($filename, $uri) {
  $wrapper = $this->streamWrapperManager
    ->getViaUri($uri);
  if (is_a($wrapper, 'Drupal\\s3fs\\StreamWrapper\\S3fsStream')) {
    return $this
      ->putObject($filename, $uri);
  }
  else {
    return $this->decorated
      ->moveUploadedFile($filename, $uri);
  }
}