Embryo/Http/Factory/UploadedFileFactory.php
public function createUploadedFileFromServer(array $files)
        {
            $normalized = [];
            foreach ($files as $key => $value) {
                
                if (!isset($value['error'])) {
                    if (is_array($value)) {
                        $normalized[$key] = $this->createUploadedFileFromServer($value);
                    }
                    continue;
                }
                
                $normalized[$key] = [];
                if (!is_array($value['error'])) {

                    if ($value['error'] === 4) {
                        $stream = (new StreamFactory)->createStream('');
                    } else {
                        $stream = (new StreamFactory)->createStreamFromFile($value['tmp_name'], 'r');    
                    }
                    
                    $normalized[$key] = $this->createUploadedFile(
                        $stream,
                        $value['size'],
                        $value['error'],
                        $value['name'],
                        $value['type']
                    );

                } else {

                    $sub = [];
                    foreach ($value['error'] as $id => $error) {
   
                        $sub[$id]['name']     = $value['name'][$id];
                        $sub[$id]['type']     = $value['type'][$id];
                        $sub[$id]['tmp_name'] = $value['tmp_name'][$id];
                        $sub[$id]['error']    = $value['error'][$id];
                        $sub[$id]['size']     = $value['size'][$id];
                        
                        $normalized[$key] = $this->createUploadedFileFromServer($sub);
                    
                    }

                }

            }
            return $normalized;
        }
public function createUploadedFileFromServer(array $files)
        {
            $normalized = [];
            foreach ($files as $key => $value) {
                
                if (!isset($value['error'])) {
                    if (is_array($value)) {
                        $normalized[$key] = $this->createUploadedFileFromServer($value);
                    }
                    continue;
                }
                
                $normalized[$key] = [];
                if (!is_array($value['error'])) {

                    if ($value['error'] === 4) {
                        $stream = (new StreamFactory)->createStream('');
                    } else {
                        $stream = (new StreamFactory)->createStreamFromFile($value['tmp_name'], 'r');    
                    }
                    
                    $normalized[$key] = $this->createUploadedFile(
                        $stream,
                        $value['size'],
                        $value['error'],
                        $value['name'],
                        $value['type']
                    );

                } else {

                    $sub = [];
                    foreach ($value['error'] as $id => $error) {
   
                        $sub[$id]['name']     = $value['name'][$id];
                        $sub[$id]['type']     = $value['type'][$id];
                        $sub[$id]['tmp_name'] = $value['tmp_name'][$id];
                        $sub[$id]['error']    = $value['error'][$id];
                        $sub[$id]['size']     = $value['size'][$id];
                        
                        $normalized[$key] = $this->createUploadedFileFromServer($sub);
                    
                    }

                }

            }
            return $normalized;
        }
public function createUploadedFileFromServer ( array $ files ) { $ normalized = [ ] ; foreach ( $ files as $ key => $ value ) { if ( ! isset ( $ value [ 'error' ] ) ) { if ( is_array ( $ value ) ) { $ normalized [ $ key ] = $ this -> createUploadedFileFromServer ( $ value ) ; } continue ; } $ normalized [ $ key ] = [ ] ; if ( ! is_array ( $ value [ 'error' ] ) ) { if ( $ value [ 'error' ] === 4 ) { $ stream = ( new StreamFactory ) -> createStream ( '' ) ; } else { $ stream = ( new StreamFactory ) -> createStreamFromFile ( $ value [ 'tmp_name' ] , 'r' ) ; } $ normalized [ $ key ] = $ this -> createUploadedFile ( $ stream , $ value [ 'size' ] , $ value [ 'error' ] , $ value [ 'name' ] , $ value [ 'type' ] ) ; } else { $ sub = [ ] ; foreach ( $ value [ 'error' ] as $ id => $ error ) { $ sub [ $ id ] [ 'name' ] = $ value [ 'name' ] [ $ id ] ; $ sub [ $ id ] [ 'type' ] = $ value [ 'type' ] [ $ id ] ; $ sub [ $ id ] [ 'tmp_name' ] = $ value [ 'tmp_name' ] [ $ id ] ; $ sub [ $ id ] [ 'error' ] = $ value [ 'error' ] [ $ id ] ; $ sub [ $ id ] [ 'size' ] = $ value [ 'size' ] [ $ id ] ; $ normalized [ $ key ] = $ this -> createUploadedFileFromServer ( $ sub ) ; } } } return $ normalized ; }
Creates a new uploaded file from server.

@param array $files
@return array
Creates a new uploaded file from server .