if ($match) { array_push($accepted_files_index, $key); } } //if file size too big, upper max upload time foreach ($_FILES['fileUpload']['size'] as $k => $s) { if ($s >= $upload_size_limit) { unset($upload_size_limit, $k); } } foreach ($_FILES['fileUpload']['error'] as $k => $e) { if ($e != 0) { unset($upload_size_limit, $e); } } //moveuploadfile foreach ($_FILES['fileUpload']['tmp_name'] as $k => $n) { foreach ($accepted_files_index as $ka) { if (is_uploaded_file($n) && $k == $ka) { $filename = $moving_url . '/' . $_FILES['fileUpload']['name'][$ka]; move_uploaded_file($n, $filename); } } } // var_dump($_FILES['fileUpload']['type']); echo '<p>final state</p>'; foreach ($accepted_files_index as $i) { echo $_FILES['fileUpload']['name'][$i] . '<br />'; } $im->updateFile(); }