classes/Upload.php
public static function capture($files = null)
    {
        $files = $files ?? $_FILES;
        if (!is_array($files)) {
            return null;
        }

        $keys = array_keys($files);
        sort($keys);
        $multi = $keys !== ['error', 'name', 'size', 'tmp_name', 'type'];
        if (!$multi && is_array($files['name'])) {
            $multi = true;
            $files = array_map(function ($index) use ($files) {
                return array_combine(array_keys($files), array_column($files, $index));
            }, array_keys($files['name']));
        }

        if ($multi) {
            return array_filter(array_map([static::class, 'capture'], $files));
        }

        return new static($files['tmp_name'], $files['name'], $files['type'], $files['error']);
    }
public static function capture($files = null)
    {
        $files = $files ?? $_FILES;
        if (!is_array($files)) {
            return null;
        }

        $keys = array_keys($files);
        sort($keys);
        $multi = $keys !== ['error', 'name', 'size', 'tmp_name', 'type'];
        if (!$multi && is_array($files['name'])) {
            $multi = true;
            $files = array_map(function ($index) use ($files) {
                return array_combine(array_keys($files), array_column($files, $index));
            }, array_keys($files['name']));
        }

        if ($multi) {
            return array_filter(array_map([static::class, 'capture'], $files));
        }

        return new static($files['tmp_name'], $files['name'], $files['type'], $files['error']);
    }
public static function capture ( $ files = null ) { $ files = $ files ?? $ _FILES ; if ( ! is_array ( $ files ) ) { return null ; } $ keys = array_keys ( $ files ) ; sort ( $ keys ) ; $ multi = $ keys !== [ 'error' , 'name' , 'size' , 'tmp_name' , 'type' ] ; if ( ! $ multi && is_array ( $ files [ 'name' ] ) ) { $ multi = true ; $ files = array_map ( function ( $ index ) use ( $ files ) { return array_combine ( array_keys ( $ files ) , array_column ( $ files , $ index ) ) ; } , array_keys ( $ files [ 'name' ] ) ) ; } if ( $ multi ) { return array_filter ( array_map ( [ static :: class , 'capture' ] , $ files ) ) ; } return new static ( $ files [ 'tmp_name' ] , $ files [ 'name' ] , $ files [ 'type' ] , $ files [ 'error' ] ) ; }
Capture uploaded files

@param array $files
@return null|Upload|Upload[]|Upload[][]|...
Capture uploaded files