How can I know a number of uploaded files with PHP?

后端 未结 4 883
深忆病人
深忆病人 2020-12-21 23:50

I have a form with several

input type=\"file\"

tags. How can I know on the server side amount of files uploaded by the user. He can upload

4条回答
  •  别那么骄傲
    2020-12-22 00:41

    You can use the count or sizeof on $_FILES array that contains uploaded file info:

     echo count($_FILES);
    

    Update (Based on comments):

    You can do this:

    $counter = 0;
    foreach($_FILES as $value){
      if (strlen($value['name'])){
        $counter++;
      }
    }
    
    echo $counter; // get files count
    

提交回复
热议问题