0

$num_of_imgs = count($images['name']);

for ($i=0; $i < $num_of_imgs; $i++) { 
    # get the image info and store them in var
    $image_name = $images['name'][$i];
    $tmp_name   = $images['tmp_name'][$i];
    $error      = $images['error'][$i];

if ($error === 0) {
        
    $img_ex = pathinfo($image_name, PATHINFO_EXTENSION);
Josua
  • 1

1 Answers1

0

Due to my low reputation I cannot add a comment :/

What to you see when run var_dump($images['name']);?

I guess this one might solve your problem:

count([$images['name']]);

Whatever $images['name'] is will be inserted into array which will allow count function to proceed.

Another option is to make sure that $images['name'] is not null. Depending on php version there might be a warning if null is passed to count function. For php => 7 will be like this:

$images = $images['name'] ?? [];

Otherwise :

$images = ($images['name']) ? $images['name'] : [];

Your questions looks like a duplication. In general would advice first google the topic and only then add a question here : ]

Tomasz Wu
  • 29
  • 3
  • I thing error appears when i add css/js from filepond, because there are nothing error when i do not use filepond – Josua Dec 31 '21 at 09:46
  • the question you posted was about why count function gives a warning. If you having issues with filepond it is a different topic I guess. Have you tried solution described in my answer? Does warning still appear? – Tomasz Wu Dec 31 '21 at 10:48
  • Yeah, i already try all of your solution and the results is another error appear – Josua Dec 31 '21 at 12:03