how to count number of input elements of html with php?

1

I need to count the number of input file elements because they are created dynamically at the click of a button

  <input class="tf" type="file" name="pic[]" accept="image/*">      

This is the line that is created dynamically, but I need to count the number of elements that were created, it does not work with count, how can I do it?

This is my php code, with the paragraph variable already right.

  <?php

$paragrafo  = isset($_POST['paragrafo']) ? $_POST['paragrafo'] : '';

$foto = isset($_FILES['pic']) ? $_FILES['pic'] : '' ;

echo count($_POST['pic']);

if(count($paragrafo) > 0 && $paragrafo != ''){
    foreach($paragrafo as $item){
        echo  $item .'<br>';
    }
} else {
    echo "Nenhum paragrafo foi adicionado!";
}

? >

    
asked by anonymous 24.10.2015 / 20:58

1 answer

-1

If this is your input $ _FILES ['pic'] then you only have a input, if you want to count the images inside it makes a sizeof($_FILES['pic']) and if you want to go through the images it makes a foreach($_FILES['pic'] as $file){ }

    
24.10.2015 / 21:18