kris_reny Posted August 23, 2009 Share Posted August 23, 2009 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. Link to comment https://forums.phpfreaks.com/topic/171489-count_filesuserfiles-always-returns-5-need-help/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 23, 2009 Share Posted August 23, 2009 Use the following code to see exactly what you are getting in the $_FILES array - <?php echo "<pre>"; echo "FILES:"; print_r($_FILES); echo "</pre>"; ?> Link to comment https://forums.phpfreaks.com/topic/171489-count_filesuserfiles-always-returns-5-need-help/#findComment-904336 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.