How can I know a number of uploaded files with PHP? [duplicate]
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 t开发者_如何学Pythonhe 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.
try
$count=0;
foreach($_FILES as $file){
if ($file["size"]>'0')$count++;
}
精彩评论