Is there way to solve php errors: undefined index+ can't upload file of this type

when I try to upload a file to my website I got this error message in php(see image belowphp error message )
of Undefined index and “Cannot upload this type of file” even though I choose an adequate format (jpg, pdf) as per my code below

    <?php

if (isset($_POST['submit'])) {
    $file = $_FILES ['file'];

$fileName = $_FILES ['file'] ['name'];
$fileTmpName = $_FILES ['file'] ['tmp_name'];
$fileSize = $_FILES ['file'] ['size'];
$fileError = $_FILES ['file'] ['error'];
$fileType = $_FILES ['file'] ['type'];

$fileExt = explode ('.',$fileName);


 $fileActualExt = strtolower (end($fileExt));

   $allowed = array ('jpg', 'jpeg', 'png', 'pdf', 'doc');

   if (in_array($fileActualExt, $allowed)) {
       if ($fileError === 0) {
           if ($fileSize < 10000000) {
            $fileNameNew = uniqid ('', true).".".$fileActualExt;
          $fileDestination = 'upload/'.$fileNameNew;
          move_uploaded_file($fileTmpName, $fileDestination);
          header ("Location : Contact.html?uploadedsuccessfully");
        } else {
            echo "Your file is too big!";
        }  

} else {
    echo "There was an error uploading your file!";
} 
} else {
    echo "You cannot upload files of this type!";
}

}  

P.S : I am testing my PHP code locally