<?php
include "classes/class.loader.php";
$db = new db();

$target_dir = "../news_upload/";
$target_file = $target_dir . basename($_FILES["image"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));

// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
    $image = null;
    // if everything is ok, try to upload file
} else {
    if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) {
        $image = $target_file;
    } else {
        $image = null;
    }
}
$db->query("INSERT INTO `news` ( `heading`, `description`, `file_name`) VALUES ('{$_POST['heading']}','{$_POST['description']}','{$_FILES["image"]["name"]}')");
echo "NEWS UPLOADED";