how to fix notice and check file on server side?
<p>I have an application <a href="http://helios.hud.ac.uk/u0867587/Files/Files.php" rel="nofollow">here</a></p>

<p>I have 2 questions:</p>

<p>Question 1: How do I fix the notice?</p>

<p>Below is the code:</p>

<pre><code>&lt;?php

If(isset($_POST)) 
{ 

$allowedImageTypes = array("image/pjpeg","image/jpeg","image/jpg","image/png","image/x-png","image/gif");
$file = $_FILES['imageFile'];  // this is the line the notice is pointing to
$fileType = $file['type'];
if (!in_array($fileType, $allowedImageTypes)) { 
    echo "Unsupported file type";
}
else
{
    // Process the file
}
}
?&gt;
</code></pre>

<p>Question 2: If you open the application, click on the "Add Question" button. This will add a table row. Now in the file input select a file which is invalid (like a .txt file for example).Now click on the "submit Details" button, it will state in an alert an "Unsupported file type" for question 1. Now go back to file input and change file to a valid format (.png, .jpg, .jpeg or .gif) and then after you have done that click on the "submit Details" button again, this time a confirmation box appears stating a message and if you want to proceed.</p>

<p>Now this all works fine on client side but what I want is that when the user clicks on the "Submit Details" button, I want it to check if the file format is correct in server side as well as client side for security purposes. If it is valid then don't show message and if invalid then show message on top "Unsupported File Type". If a file input is blank then it is valid but if one file input contains the wrong file format, then display the invalid message. Does anyone know how to do this? Is the php code nearly there from achieving this?</p>

<p>You can view full code in view source if you wish</p>
