protected function prepareArrayBasedFileInput(&$uploads, $key, $file)
    {
        preg_match_all('/([^\[\]]+)/', $key, $segments);

        $segments = array_reverse($segments[1]);

        $newKey = array_pop($segments);

        foreach ($segments as $segment) {
            $file = [$segment => $file];
        }

        $uploads[$newKey] = $file;

        unset($uploads[$key]);
    }