forked from mailru/FileAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FileAPI.class.php
38 lines (31 loc) · 1.07 KB
/
FileAPI.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
class FileAPI {
private static $_files = null;
private static function init(){
if( is_null(self::$_files) ){
self::$_files = array();
// http://www.php.net/manual/ru/reserved.variables.files.php#106558
foreach( $_FILES as $firstNameKey => $arFileDescriptions ){
foreach( $arFileDescriptions as $fileDescriptionParam => $mixedValue ){
self::rRestructuringFilesArray(self::$_files, $firstNameKey, $_FILES[$firstNameKey][$fileDescriptionParam], $fileDescriptionParam);
}
}
}
}
private static function rRestructuringFilesArray(&$arrayForFill, $currentKey, $currentMixedValue, $fileDescriptionParam){
if( is_array($currentMixedValue) ){
foreach( $currentMixedValue as $nameKey => $mixedValue ){
self::rRestructuringFilesArray($arrayForFill[$currentKey],
$nameKey,
$mixedValue,
$fileDescriptionParam);
}
} else {
$arrayForFill[$currentKey][$fileDescriptionParam] = $currentMixedValue;
}
}
public static function getFiles(){
self::init();
return self::$_files;
}
}