bored

A micro PHP framework
git clone git://git.bitsmanent.org/bored
Log | Files | Refs | README

commit 774dbb608fd4f303b7dda629298fa73c73951bc9
parent 8b8ac50864ae09d1128df0dedaab3179e2181366
Author: Claudio Alessi <smoppy@gmail.com>
Date:   Wed, 26 Jun 2019 16:11:57 +0200

Improve prepare_form() to deal with multiple file groups.

Diffstat:
Mbored.php | 27+++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/bored.php b/bored.php @@ -439,26 +439,21 @@ function curl_post($uri, $curlopts = []) { } function prepare_form() { - $key = key($_FILES); - if(!$key) - return; - $files = @$_FILES[$key]; - if(@$_POST[$key]) { - $files = array_merge($files, $_POST[$key]); - unset($_POST[$key]); - } $ret = []; - if(is_array($files['name'])) { - foreach($files as $k => $unused) { - foreach($files[$k] as $i => $v) { - if(!isset($ret[$i])) - $ret[$i] = []; - $ret[$i][$k] = $v; + $idx = 0; + foreach($_FILES as $grp => $fds) { + foreach($fds as $k => $vals) { + foreach($vals as $i => $txt) { + $t = $idx + $i; + if(!isset($ret[$t])) { + $ret[$t] = []; + $ret[$t]["grp"] = $grp; + } + $ret[$t][$k] = $txt; } } + $idx += count($ret); } - else - $ret = [$files]; $_FILES = $ret; }