Jump to content

count($_FILES['userfiles']) always returns 5. Need help


kris_reny

Recommended Posts

I have the following php script which counts the number of file input fields in myform

<?php	if(isset($_POST['submit'])) 
{		
$i = 0;
while($i <= count($_FILES['fileupload']))
{
print $i;		
print $_FILES['fileupload']['name'][$i]."<br />";	
$i++;		
}

}
?>

 

The HTML is as follows

<html><body><form name="upload" method="post" action="" enctype="multipart/form-data">
<table>
<tr>
<td>
<input type="file" name="fileupload[]">

</td>
</tr>
<tr>
<td>
<input type="file" name="fileupload[]">

</td>
</tr>
<tr>
<td>
<input type="file" name="fileupload[]">

</td>
</tr>
<tr>
<td>
<input type="file" name="fileupload[]">

</td>
</tr>
<tr>
<td>
<input type="file" name="fileupload[]">

</td>
</tr>
<tr>
<td>
<input type="file" name="fileupload[]">

</td>
</tr>
  
<tr>
<td>
<input type="submit" name="submit">

</td>
</tr>
</table>

 

The

count($_FILES['fileupload'])
line in my code returns 5 eventhough I have six or more input fields in the form.

If i select five  images and hit submit, then the code returns me the image names of selected five images. But it doesn't return any thing if I select more than five files.

count($_FILES['fileupload'])
return "5" even if I have  "3" input fields in the form

Can any one help me to solve this issue? Iam stuck!!! Thankyou in advance.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.