CoreFiles by mySites.guru
create_uploaded_file.php37 lines, 937 bytes, from Joomla_6.2.1-Stable-Full_Package.zip
Raw History Compare with 6.2.0
md5
2cb765366ce9da5fd9221219c6c5e7fe
sha1
81dd90ff86c3e37c8fe40440c9f96d3d8493ae98
sha256
15a88d7d1cb2357dc7db98f4c886ae6594e6715632ae423d06030f70c9c737c2
<?php

declare(strict_types=1);

namespace Laminas\Diactoros;

use function sprintf;

/**
 * Create an uploaded file instance from an array of values.
 *
 * @param array $spec A single $_FILES entry.
 * @throws Exception\InvalidArgumentException If one or more of the tmp_name,
 *     size, or error keys are missing from $spec.
 */
function createUploadedFile(array $spec): UploadedFile
{
    if (
        ! isset($spec['tmp_name'])
        || ! isset($spec['size'])
        || ! isset($spec['error'])
    ) {
        throw new Exception\InvalidArgumentException(sprintf(
            '$spec provided to %s MUST contain each of the keys "tmp_name",'
            . ' "size", and "error"; one or more were missing',
            __FUNCTION__
        ));
    }

    return new UploadedFile(
        $spec['tmp_name'],
        (int) $spec['size'],
        $spec['error'],
        $spec['name'] ?? null,
        $spec['type'] ?? null
    );
}

The same content is in 158 releases, Joomla 5.0.0-alpha1 to 6.3.0-alpha1. See them all, or every version of this file.