For some reason when I upload a document and store the file name in mysql table the file name extension isn't included in the name. For example, I upload the pdf file "car.pdf" and the way it is stored in mysql table is "car."(see period right after the word, The file extension is not included). I have checked this website, I have googled it too, but can't find a clear answer.
$doc_name = mysqli_real_escape_string($dbc, trim($_FILES['doc']['name']));
$doc_type = $_FILES['doc']['type'];
$doc_size = $_FILES['doc']['size'];
if(!empty($title)){
if(!empty($doc_name)){
if (($doc_type == 'application/pdf') || ($doc_type == 'application/msword') || ($doc_type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document')){
if(($doc_size > 0) && ($doc_size <= FILE_MAXFILESIZE)){
if ($_FILES['doc']['error'] == 0) {
$final_name = time() . $doc_name;
$target = $uploadpath . $final_name;
if(move_uploaded_file($_FILES['doc']['tmp_name'], $target)) {
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die ('There was a problem with your query. Please, contact administrator');
if(!empty($description)){
$query = "INSERT INTO uploaded_files (file, title, description, date_time, user_id, dep_id) VALUES ('$final_name', '$title', '$description', now(), '" . $_SESSION['user_id'] . "', '$dep_id')";
}.... rest of the code goes here