0
I’m trying to go through an array of various images in PHP, however, I’m not getting it, follow the code below:
HTML:
 <input type="file" name="img[]" onchange="this.parentNode.setAttribute('title', this.value.replace(/^.*[\\/]/,''))" />
 <input type="file" name="img[]" onchange="this.parentNode.setAttribute('title', this.value.replace(/^.*[\\/]/,''))" />
 <input type="file" name="img[]" onchange="this.parentNode.setAttribute('title', this.value.replace(/^.*[\\/]/,''))" />
PHP:
    $tipos_img = array(
    "image/jpg",
    "image/png",
    "image/jpeg"
   );
   $verifica_quant_img = 0;
   $caminho_fixo = "itens_fixos/imgjogos/";
 foreach ($_FILES['img'] as $img){    
    if (!empty($img['name'])){
          $verifica_quant_img = $verifica_quant_img + 1;
        $caminho = "itens_fixos/imgjogos/".$img['name'];
    if (!in_array($tipos_img, $img['type'])){
     echo "<script language='javascript' type='text/javascript'>alert('Os formatos de imagens aceitos são, 'JPG','PNG' e 'JPEG'.');window.location.href='indexjogo.php';</script>";
        exit;
    }
    if ($img['size'] > 3145728){
        echo "<script language='javascript' type='text/javascript'>alert('Tamanho máximo das imagens é de 3MBs.');window.location.href='indexjogo.php';</script>";
        exit;
    }
    if (file_exists($caminho)){
            echo "<script language='javascript' type='text/javascript'>alert('A imagem"+$img['name']+" já existe.');window.location.href='indexjogo.php';</script>";
        exit;
    }
    }
}

What would be the problem?
– Sam
This one below the code.
– shelldude
rsrs truth.. had not noticed. Thanks!
– Sam
Take a look https://jsfiddle.net/3bhjfg9y/1/
– Sam