flush
[mdref/mdref-http] / http / Env / Request / getFiles.md
1 # array http\Env\Request::getFiles()
2
3 Retrieve the uploaded files list ($_FILES).
4
5 ## Params:
6
7 None.
8
9 ## Returns:
10
11 * array, the consolidated upload files array.
12
13 ## Example:
14
15 Here's an example how the original $_FILES array and the http\Env\Request's files array compare:
16
17 $r = new http\Env\Request;
18 $f = array();
19
20 foreach ($_FILES as $name => $data) {
21 foreach ((array) $data["tmp_name"] as $i => $file) {
22 $f[$name][$i] = array(
23 "file" => $file,
24 "name" => $data["name"][$i],
25 "size" => $data["size"][$i],
26 "type" => $data["type"][$i],
27 "error"=> $data["error"][$i]
28 );
29 }
30 }
31 assert($f == $r->getFiles());
32
33 You can see that the second and third dimensions are swapped and ```tmp_name``` became ```file```, e.g:
34
35 array(
36 "upload" => array(
37 array(
38 "file" => "/tmp/phpXXXXXX",
39 "name" => "picture.jpeg",
40 "size" => 12345,
41 "type" => "image/jpeg",
42 "error"=> 0
43 )
44 )
45 );