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

Breadcrumb

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

function ServerRequest::normalizeFiles

Return an UploadedFile instance array.

Parameters

array $files An array which respect $_FILES structure:

Throws

InvalidArgumentException for unrecognized values

1 call to ServerRequest::normalizeFiles()
ServerRequest::fromGlobals in vendor/guzzlehttp/psr7/src/ServerRequest.php
Return a ServerRequest populated with superglobals: $_GET $_POST $_COOKIE $_FILES $_SERVER

File

vendor/guzzlehttp/psr7/src/ServerRequest.php, line 87

Class

ServerRequest
Server-side HTTP request

Namespace

GuzzleHttp\Psr7

Code

public static function normalizeFiles(array $files) : array {
    $normalized = [];
    foreach ($files as $key => $value) {
        if ($value instanceof UploadedFileInterface) {
            $normalized[$key] = $value;
        }
        elseif (is_array($value) && isset($value['tmp_name'])) {
            $normalized[$key] = self::createUploadedFileFromSpec($value);
        }
        elseif (is_array($value)) {
            $normalized[$key] = self::normalizeFiles($value);
            continue;
        }
        else {
            throw new InvalidArgumentException('Invalid value in files specification');
        }
    }
    return $normalized;
}

API Navigation

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