多个附件中的FileSize

I am sending multiple attachments with an Email Message, Now i want to check the Extension and Size of the Attached File, For which i am using the Code:

foreach(array_keys($_FILES['attachment']['name']) as $key) {

  $file=$_FILES['attachment'];
  $filesize = (filesize($file) * .0009765625) * .0009765625;

  echo $filesize;
  if ($FileSize > 100) {
    echo "<script type='text/javascript'>parent.document.getElementById('sizeerrormessage').style.display = 'inline';</script>";
  }
  $source = $_FILES['attachment']['tmp_name'][$key];
  $filename = $_FILES['attachment']['name'][$key];

  $mail->AddAttachment($source, $filename);
}

I gives error that for calculating File Size and Extension an array is given, string required.

For Multiple Attachments, attachment[] is an arrray.. How to check the file size and extension of an array type now The Form Code is

<input type="file" name="attachment[]" id="attachment" size="30"
onchange="document.getElementById('moreUploadsLink').style.display = 'block';" />
<div id="moreUploads"></div>
<div id="sizeerrormessage" style="display:none;margin-left:30px">
 <font color=#990000 size=1>File exceeded maximum allowed limit of 100 Kb</font>
 </div>
 <div id="typeerrormessage" style="display:none;margin-left:30px">
 <font color=#990000 size=1>Only png, jpg and gif are allowed extensions.</font>
 </div>
 <div id="moreUploadsLink" style="display:none;"><a
  href="javascript:addFileInput();">Attach another File</a></div>

And the javascript is

<script type="text/javascript">
 var upload_number = 1;
 var attachmentlimit = 5;
 function addFileInput() {

  var d = document.createElement("div");
  var file = document.createElement("input");
  file.setAttribute("type", "file");
  file.setAttribute("name", "attachment[]");
  /*    file.setAttribute("name", "attachment"+upload_number);*/
  d.appendChild(file);
    document.getElementById("moreUploads").appendChild(d);
  upload_number++;
   if(upload_number == attachmentlimit) {
  document.getElementById('moreUploadsLink').style.display='none';
   }

  }
  </script>

This is how you get the filesize and extension using your script

$filesize = $_FILES['attachment']['size'][$key];
$extention = pathinfo ($_FILES['attachment']['name'][$key] ,PATHINFO_EXTENSION );

For information please see

http://php.net/manual/en/reserved.variables.files.php

http://php.net/manual/en/function.pathinfo.php

Thanks

:)