lithium\action\Request::_parseFiles()

protected method

Normalizes the data from the $_FILES superglobal.

Parameters

  • array $data

    Data as formatted in the $_FILES superglobal.

Returns

array

Normalized data.

Source

	protected function _parseFiles($data) {
		$result = [];

		$normalize = function($key, $value) use ($result, &$normalize){
			foreach ($value as $param => $content) {
				foreach ($content as $num => $val) {
					if (is_numeric($num)) {
						$result[$key][$num][$param] = $val;
						continue;
					}
					if (is_array($val)) {
						foreach ($val as $next => $one) {
							$result[$key][$num][$next][$param] = $one;
						}
						continue;
					}
					$result[$key][$num][$param] = $val;
				}
			}
			return $result;
		};
		foreach ($data as $key => $value) {
			if (isset($value['name'])) {
				if (is_string($value['name'])) {
					$result[$key] = $value;
					continue;
				}
				if (is_array($value['name'])) {
					$result += $normalize($key, $value);
				}
			}
		}
		return $result;
	}