First of all, note that in your array
not the name
or tmp_name
key that is common when using $_FILES
in PHP.
In this way I assume that you must be using the wrong method to capture the form data. (you should be using $_POST
).
Generally when you want to do a upload of file (s), use:
<form action="upload.php" enctype="multipart/form-data" method="post">
<input type="file" name="imagens[$id][]">
</form>
Note that form is method="post"
, however in PHP you should capture it by $_FILES
. What should generate an array like this:
Array
(
[45] => Array
(
[0] => Array
(
[name] => 1.jpg
[type] => image/jpeg
[tmp_name] => /tmp/php/php6hst32
[size] => 98174
)
[1] => Array
(
[name] => 2.jpg
[type] => image/jpeg
[tmp_name] => /tmp/php/php6hst32
[size] => 98174
)
)
[44] => Array
(
[0] => Array
(
[name] => 4.jpg
[type] => image/jpeg
[tmp_name] => /tmp/php/php6hst32
[size] => 98174
)
)
)
To manipulate your content you can use foreach
:
foreach($_FILES as $id => $files){
foreach($files as $k => $file){
$name = $file['name'];
$tmpName = $file['tmp_name'];
printf("name : %s\n tmpName : %s", $name, $tmpName);
}
}