问题
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