At work, I deal with complex forms (publishing Symphony pages ) that contain several image loading fields. I need a way to quickly merge $_FILESwith $_POST, unfortunately, you cannot just combine the two with array_merge, because they do not follow the same structure.
Basically, if you have it $_POST[a][b], it will $_FILES[a][*][b]. Replace *one of the name, type, tmp_name, erroror size.
Array contents $_FILESas standard:
array
'image-a' => array
'name' => string '' (length=0)
'type' => string '' (length=0)
'tmp_name' => string '' (length=0)
'error' => int 4
'size' => int 0
'image-b' => array
'name' => string '' (length=0)
'type' => string '' (length=0)
'tmp_name' => string '' (length=0)
'error' => int 4
'size' => int 0
'image' => array
'name' => array
'sub' => array
'c' => string '' (length=0)
'type' => array
'sub' => array
'c' => string '' (length=0)
'tmp_name' => array
'sub' => array
'c' => string '' (length=0)
'error' => array
'sub' => array
'c' => int 4
'size' => array
'sub' => array
'c' => int 0
And the desired array after merging with $_POST:
array
'MAX_FILE_SIZE' => string '5242880' (length=7)
'image-a' => array
'name' => string '' (length=0)
'type' => string '' (length=0)
'tmp_name' => string '' (length=0)
'error' => int 4
'size' => int 0
'image-b' => array
'name' => string '' (length=0)
'type' => string '' (length=0)
'tmp_name' => string '' (length=0)
'error' => int 4
'size' => int 0
'image' => array
'sub' => array
'c' => array
'name' => string '' (length=0)
'type' => string '' (length=0)
'tmp_name' => string '' (length=0)
'error' => int 4
'size' => int 0