Good morning, I'm doing a function to upload multiple images, but in PHP comes only the last. Here are my codes:
HTML
<form id="msform" action="../controllers/controllerCadastraImagemProduto.php" method="POST" enctype="multipart/form-data">
<input type='file' name="imagensPB[]" multiple>
</form>
PHP
$i=0;
foreach ($_FILES["imagensPB"]["error"] as $key => $error) {
//Get the temp file path
$tmpFilePath = $_FILES['imagensPB']['tmp_name'][$i];
//Make sure we have a filepath
if ($tmpFilePath != ""){
//Setup our new file path
$newFilePath = "../img/produtos/" . $_FILES['imagensPB']['name'] [$i];
//Upload the file into the temp dir
if(move_uploaded_file($tmpFilePath, $newFilePath)) {
}
}
$i++;
}
Where can I be wrong?