summaryrefslogtreecommitdiffstats
path: root/application/helpers
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2013-01-17 18:54:35 +0100
committerFlorian Pritz <bluewind@xinu.at>2013-01-17 21:25:44 +0100
commite1e658c6547a2b00a2b5b32bf3cd34ab8a5f2a52 (patch)
treef26e9ef785ff1d2f8d23b7235fb991e93d5e6d1c /application/helpers
parentdc3afcb35744ec5d9036fc329dab25f0c8dcd7a5 (diff)
Support multiple uploads in the same request
This change *should* be backwards compatible. Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/helpers')
-rw-r--r--application/helpers/filebin_helper.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/application/helpers/filebin_helper.php b/application/helpers/filebin_helper.php
index 2f073c902..0951527fe 100644
--- a/application/helpers/filebin_helper.php
+++ b/application/helpers/filebin_helper.php
@@ -256,4 +256,32 @@ function handle_etag($etag)
}
}
+// Reference: http://php.net/manual/en/features.file-upload.multiple.php#109437
+// This is a little different because we don't care about the fieldname
+function getNormalizedFILES()
+{
+ $newfiles = array();
+ $ret = array();
+
+ foreach($_FILES as $fieldname => $fieldvalue)
+ foreach($fieldvalue as $paramname => $paramvalue)
+ foreach((array)$paramvalue as $index => $value)
+ $newfiles[$fieldname][$index][$paramname] = $value;
+
+ $i = 0;
+ foreach ($newfiles as $fieldname => $field) {
+ foreach ($field as $file) {
+ // skip empty fields
+ if ($file["error"] === 4) {
+ continue;
+ }
+ $ret[$i] = $file;
+ $ret[$i]["formfield"] = $fieldname;
+ $i++;
+ }
+ }
+
+ return $ret;
+}
+
# vim: set noet: