How to check what file is uploaded
<p>I am new to PHP and I wanna check the file before it is uploaded to PhpMyAdmin. The only file types I wanna add to my database are PDF, DOC and DOCX. I have checked on the internet for the solution but I really can't find any. I hope you guys can help me with this.</p>

<pre><code>&lt;?php
$servername = "localhost";
$username = "root";
$password = "usbw";
$dbname = "persons";

// CREATE A CONNECTION WITH THE DATABASE
// CONNECTIE MAKEN MET DATABASE
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn-&gt;connect_error) {
die("Connection failed: " . $conn-&gt;connect_error);
} 

// CHECK IF SUBMIT IS CLICKED
// CONTROLEER OF SUBMIT IS GEKLIKT
if(isset($_POST['submit']))
{
$filetmp = $_FILES["cv"]["tmp_name"];
$filename = $_FILES["cv"]["name"];
$filetype = $_FILES["cv"]["type"];
$filepath = "files/".$filename;

move_uploaded_file($filetmp,$filepath);


// INSERT VALUES IN THE DATABASE
// VOEG WAARDES TOE IN DE DATABASE
$sql = "INSERT INTO cv (cv_name,cv_path,cv_type) VALUES ('$filename','$filepath','$filetype')";
$result = mysqli_query($conn, $sql);
}
// INSERT cv_id IN person_id
// VOEG cv_id TOE IN person_id
$cv = $conn-&gt;insert_id;
?&gt;
</code></pre>