note 98076 deleted from features.file-upload.post-method by danbrown

From: Date: Thu, 30 Sep 2010 14:39:03 +0000
Subject: note 98076 deleted from features.file-upload.post-method by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-172848@lists.php.net to get a copy of this message
Note Submitter: rusarmy at gmail dot com ---- As daevid noticed, the structure of $_FILES array is rather strange. Here is the way to fix it: <?php function sortFiles() { $sortedFiles = array(); foreach ($_FILES as $key => $file) { $sortedFiles[$key] = array(); if (is_int($file['error'])) { $sortedFiles[$key] = $file; } elseif (is_array($file['error'])) { $sortedFiles[$key] = array(); $params = array('error', 'size', 'name', 'tmp_name', 'type'); foreach ($params as $param) { subSortFiles($file[$param], $sortedFiles[$key], $param); } } } $_FILES = $sortedFiles; } function subSortFiles(&$arr, &$mask, $param) { foreach ($arr as $key => $value) { if (!is_array($mask[$key])) { $mask[$key] = array(); } if (is_array($value)) { subFixFiles($value, $mask[$key], $param); } else { $mask[$key][$param] = $value; } } } ?>

« previous php.notes (#172848) next »