method getFiles documentation in bbn\Mvc\Environment
function()
{
if (!isset($this->_files)) {
$this->_files = [];
// Rebuilding the $_FILES array into $this->_files in a more logical structure
if (\count($_FILES) > 0) {
// Some devices send multiple files with the same name
$names = [];
foreach ($_FILES as $n => $f) {
if (\is_array($f['name'])) {
$this->_files[$n] = [];
foreach ($f['name'] as $i => $v) {
while (\in_array($v, $names, true)) {
if (!isset($j)) {
$j = 0;
}
$j++;
$file = bbn\Str::fileExt($f['name'][$i], true);
$v = $file[0] . '_' . $j . '.' . $file[1];
}
$this->_files[$n][] = [
'name' => $v,
'tmp_name' => $f['tmp_name'][$i],
'type' => $f['type'][$i],
'error' => $f['error'][$i],
'size' => $f['size'][$i],
];
$names[] = $v;
}
} else {
while (\in_array($f['name'], $names, true)) {
if (!isset($jj)) {
$jj = 0;
}
$jj++;
$file = bbn\Str::fileExt($f['name'], true);
$f['name'] = $file[0] . '_' . $jj . '.' . $file[1];
}
$this->_files[$n] = $f;
$names[] = $f['name'];
}
}
}
/* @todo Maybe something for managing PUT requests
else if (!empty(self::$_input) && !bbn\Str::isJson(self::$_input)) {
$this->_files[] = [
'name' => $v,
'tmp_name' => $f['tmp_name'][$i],
'type' => $f['type'][$i],
'error' => $f['error'][$i],
'size' => $f['size'][$i],
];
}
*/
}
return $this->_files;
}
BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2025
BBN Solutions