使用输入字段上载文件

I have included the file type check it the below code. If i select 2 files from allowed type and one file from not allowed type the code still save the allowed one and show the msg for the file type as well. I want if any file is other than the allowed one the code should not save any thing.

<?php
// Script written by Adam Khoury for the following video exercise:
// http://www.youtube.com/watch?v=7fTsf80RJ5w
if(isset($_FILES['file_array'])) {
    $name_array = $_FILES['file_array']['name'];
    $tmp_name_array = $_FILES['file_array']['tmp_name'];
    $type_array = $_FILES['file_array']['type'];
    $size_array = $_FILES['file_array']['size'];
    $error_array = $_FILES['file_array']['error'];

    for($i = 0; $i < count($tmp_name_array); $i++){

        $fileext [$i] = explode('.', $name_array[$i]);
        $fileactualext[$i] = strtolower(end($fileext[$i]));
        $allowed = array("jpg","jpeg", "pdf");

        if (in_array($fileactualext[$i], $allowed)) {
            if(move_uploaded_file($tmp_name_array[$i], "test_uploads/".$name_array[$i])) {
                    echo $name_array[$i]."upload is complete<br>";
            } else {
                    echo "move_uploaded_file function failed for ".$name_array[$i]."<br>";
                    }

        } else {
                header('location:file_type.php');
                }
    }
}
?>

Use the following code to check for image size, type, error,

$file_ext=strtolower(end(explode('.',$_FILES['file_array']['name'])));

  $extensions= array("jpeg","jpg","png");

if(in_array($file_ext,$extensions)=== false){
        $errors[]="extension not allowed, please choose a JPEG or PNG file.";
 }

 if($file_size > 2097152){ // set whatever max size you want
       $errors[]='File size must be excately 2 MB';
 }

 if(empty($errors)==true){
       move_uploaded_file($file_tmp,"images/".$file_name);
       echo "Success";
 }else{
      print_r($errors);
 }