i have this code which has a form where users can upload 5 pictures. after the form is submitted i try to count the elements in the array but i always get 15 even though here are only 5. below is the simplified testing code (i removed the upload stuff for testing purposes)
what im trying to eventually have is just a form field with 5 inputs to choose 5 files to upload. when the form is submitted the script puts the values of the inputs into an array. and if they only filled in the inputs for 3 files out of the 5 available, the array would only contain 3 elements.
THE FORM
<form name="form1" enctype="multipart/form-data" method="post" action="test2.php">
<input name="userpicture0" type="file"></p>
<input name="userpicture1" type="file"></p>
<input name="userpicture2" type="file"></p>
<input name="userpicture3" type="file"></p>
<input name="userpicture4" type="file"></p>
<input name="userpicture[]" type="hidden" value="5">
<input type="submit" name="Submit" value="upload">
</form>
THE TEST PROCESSING CODE
$count = count($_POST['userpicture']);
echo "COUNT = $count";
for($i=0; $i<; $i++)
{
echo "$userpicture[$i]<br>";
}
THE RESULTS
COUNT = 15