<?php
// if there is post
if (isset($_POST)&& !empty($_POST)){
//if there is an attachment
if (!empty($_FILES['attachment']['name'])){
//store some variable
$file_name = $_FILES['attachment']['name'];
$temp_name = $_FILES['attachment']['tmp_name'];
$file_type = $_FILES['attachment']['type'];
//get the extension of the file
$base = basename($file_name);
$extension = substr(&$base, strlen($base)-4,strlen($base));