文件按钮使用循环

I have som doubt in the following code.

file.php

<form method="post" action="Filesave.php" enctype="multipart/form-data">
<?php
   for($i=0;$i<25;$i++) {
?>
   <input type="file" id="f[]" name="f[]">
<?php
   }
?>
   <br />
   <br />
   <input type="submit" name="submit" id="submit" value="Submit"/>
</form>

filesave.php

<?php
   for($i=0;$i<25;$i++) {
      $image = $_FILES["f"]["name"][$i];
      $filepath = $_FILES['f']['tmp_name'][$i];
      echo($i." Image Name ".$image." File Path ".$filepath."<br>");
   }
?>

In the above code after 20th iteration the following error will be displayed.

Notice: Undefined offset: 20 in C:\wamp\www\IMGUpload\Filesave.php on line 4 Notice: Undefined offset: 20 in C:\wamp\www\IMGUpload\Filesave.php on line 5

Please tell how to solve this problem?

That's because you're looping through 26 indexes in $_FILES['f'] where the case could've been that you only uploaded 19 images (i.e 19 indexes). Since the images that could be uploaded are variable, you need to use the count() function to determine how many images are sent for uploading.

filesave.php

$image_count = count($_FILES['f']['tmp_name']);
for($i=0;$i<$image_count-1;$i++) {
  $image = $_FILES["f"]["name"][$i];
  $filepath = $_FILES['f']['tmp_name'][$i];
  echo($i." Image Name ".$image." File Path ".$filepath."<br>");
}