<?php
include("../../db.php");
error_reporting(E_ALL);
header("Access-Control-Allow-Origin: * ");

$file_name = $_REQUEST['file_name'];

if ($file_name == null || $file_name == "") {
    echo json_encode(array('status' => 0, 'msg' => 'file name is needed'));
    return;
}

$resFile = $db->delete("practice_question_files","where name='".$file_name."' ");

unlink("../../uploads/practice/" . $file_name);

if ($resFile != "") {
    echo json_encode(array('status' => 1, 'msg' => 'File deleted Successfully', "file_name"=>$file_name));

} else {
    echo json_encode(array('status' => 0, 'msg' => 'Unable to delete file. Please Try Again..!'));
}