The $_FILES
has very I'd say unique structure,
I know the intend is to maintain the multi-dimention keys,
the behaviour is predictable but it's hard to iterate.
The single purpose of this class is to move the value's keys to the leaf node.
You can even modify to make the leaf node as an object with move
method to even ease up the upload mechanism.
// original
print_r($_FILES);
// restructured
print_r(UploadedFile::build());
// original
Array
(
[one] => Array
(
[name] => ss_break.png
[type] => image/png
[tmp_name] => /tmp/phppY8lSV
[error] => 0
[size] => 43582
)
[multiple] => Array
(
[name] => Array
(
[0] => LeleBreeder.png
)
[type] => Array
(
[0] => image/png
)
[tmp_name] => Array
(
[0] => /tmp/php6GSj1X
)
[error] => Array
(
[0] => 0
)
[size] => Array
(
[0] => 14284
)
)
[crazy] => Array
(
[name] => Array
(
[nested] => Array
(
[keys] => PlainUbuntu.png
)
)
[type] => Array
(
[nested] => Array
(
[keys] => image/png
)
)
[tmp_name] => Array
(
[nested] => Array
(
[keys] => /tmp/php4boHkj
)
)
[error] => Array
(
[nested] => Array
(
[keys] => 0
)
)
[size] => Array
(
[nested] => Array
(
[keys] => 25668
)
)
)
)
// restructured
Array
(
[one] => Array
(
[originalPath] => ss_break.png
[path] => /tmp/phppY8lSV
[contentType] => image/png
[size] => 43582
[errorCode] => 0
)
[multiple] => Array
(
[0] => Array
(
[originalPath] => LeleBreeder.png
[path] => /tmp/php6GSj1X
[contentType] => image/png
[size] => 14284
[errorCode] => 0
)
)
[crazy] => Array
(
[nested] => Array
(
[keys] => Array
(
[originalPath] => PlainUbuntu.png
[path] => /tmp/php4boHkj
[contentType] => image/png
[size] => 25668
[errorCode] => 0
)
)
)
)