Php 如何知道$\u文件数组何时为空

Php 如何知道$\u文件数组何时为空,php,Php,如何知道文件不包含图像,并相应地修改代码? 我想要像这样的东西: if(expression_that_check_FILES_array_isnot_empty) { do sth; } else { do sthElse; } 请尝试: if($_FILES['file']['name']!="") { do sth; } else { do sthElse; } 试试这个 if(!empty($_FILES['file']['name'])) { do s

如何知道文件不包含图像,并相应地修改代码? 我想要像这样的东西:

if(expression_that_check_FILES_array_isnot_empty)
{
   do sth;
}
else
{
   do sthElse;
}
请尝试:

if($_FILES['file']['name']!="")
{
   do sth;
}
else
{
   do sthElse;
}
试试这个

if(!empty($_FILES['file']['name']))
{
   do sth;
}
else
{
   do sthElse;
}
你能试试吗

if(!isset($_FILES["file"]["size"]) || ($_FILES["my_file_name"]["size"] == 0) || (!empty($_FILES["file"]["name"]) {
    do sth; // Throw Error
} else {
   do sthElse; //Upload 
}
感谢他在评论中的回答。 我用了这个:

if (!empty($_FILES)){
   do sth;
}
else{
   do sthElse;
}

你试过empty()或isset()吗?那
empty
子句呢<代码>如果(!empty($\u FILES)){…谢谢你们两位,这很好。我想要不需要文件名的东西。