如何在多文件上载PHP中查看数组是否为空

如何在多文件上载PHP中查看数组是否为空,php,error-handling,Php,Error Handling,使用php多重上传脚本,如何检查数组是否为空? 不起作用: if(空($\u文件['images']['name'])) if($\u文件['images']['name']=='Array') 使用for循环作为第一个检查似乎有问题。然后在第一个for循环中有一个嵌套的if语句。然后,在该循环中有另一个for循环,用于额外的错误检查。 最好的方法是什么?这不显示数组是否为空。第一次检查仅检查计数($images)>5 //开始图像验证 if(isset($name)){//这里我想看看图像

使用php多重上传脚本,如何检查数组是否为空?
不起作用:

  • if(空($\u文件['images']['name']))
  • if($\u文件['images']['name']=='Array')
  • 使用for循环作为第一个检查似乎有问题。然后在第一个for循环中有一个嵌套的if语句。然后,在该循环中有另一个for循环,用于额外的错误检查。
最好的方法是什么?这不显示数组是否为空。第一次检查仅检查计数($images)>5

//开始图像验证
if(isset($name)){//这里我想看看图像数组是否为空
//最多允许5个图像
如果(计数($name)>5){
?>
document.getElementById('message')。innerHTML+='允许的最大图像数为5';

要计算成功上载的文件数和尝试上载的文件数:

<?php

$successfully_uploaded_files = 0;
$attempted_files = 0;

foreach ($_FILES as $file) {
  if ($file['error'] === 0) {
    $successfully_uploaded_files++;
    $attempted_files++;
  } elseif ($file['error'] !== 4) {
    $attempted_files++;
  }
}

请改进您的问题。
<?php

$successfully_uploaded_files = 0;
$attempted_files = 0;

foreach ($_FILES as $file) {
  if ($file['error'] === 0) {
    $successfully_uploaded_files++;
    $attempted_files++;
  } elseif ($file['error'] !== 4) {
    $attempted_files++;
  }
}