Need Help to count input fields---- count($_FILES['file'])
Posted: Sun Aug 23, 2009 2:00 am
I have the following php script which counts the number of file input fields in myform
The HTML is as follows
The
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.
Can any one help me to solve this issue? Thank-you in advance
Code: Select all
<?php if(isset($_POST['submit']))
{
$i = 0;
while($i <= count($_FILES['fileupload']))
{
print $i;
print $_FILES['fileupload']['name'][$i]."<br />";
$i++;
}
}
?>Code: Select all
<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>line in my code returns 5 eventhough I have six or more input fields in the form.count($_FILES['fileupload'])
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.
Can any one help me to solve this issue? Thank-you in advance