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

北城余情 提交于 2020-01-17 14:03:48

问题


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

Hello, I have a form with three

input type="file"

tags. How can I know on the server side amount of files uploaded by the user? He can upload 3 files, or may be 2 files, 1 or even nothing. I need to know how much files user have uploaded.

If I use the code

echo count($_FILES);

It will always display the value of 3. Because form contains three file fields. If the user will upload only two files, the code will display 3, but the right value is 2.


回答1:


try

$count=0;
foreach($_FILES as $file){
if ($file["size"]>'0')$count++;
}


来源:https://stackoverflow.com/questions/4368107/how-can-i-know-a-number-of-uploaded-files-with-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!