PHP does not recognize all multiple input files

0

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?

    
asked by anonymous 12.01.2016 / 13:51

1 answer

0

If you do not find a solution you can try using Uploadify. Uploadify

    
12.01.2016 / 15:24