This is the code which inserts data into the database. and the result is sent back to the ajax code.
<?php
if (isset($_FILES['files']['name'])) {
    $files = $_FILES['files']['name'];
    $desc = $_POST['description'];
    $subject = $_POST['subject'];
    $path = 'Lectures/' . $files;
    move_uploaded_file($_FILES["files"]["tmp_name"], $path);
    $date = date('d-M-y');
    $query = "INSERT INTO content(file_name,course_code,description,file_path,upload_date) VALUES ('$files','$subject','$desc','$path','$date')";
    $cm = sqlsrv_query($conn, $query);
    if ($cm) {
        $result['status'] = "Succsess";
    } else {
        $result['status'] = "failed";
    }
    echo json_encode($result);
}
And this is the Ajax Success: function.it executes only the else portion even if the condition is true.
success: function(output) {
    alert(output);
    if(output.status == "Succsess")
    { 
        alertify.success('Success message');
    }else{
        alertify.set('notifier','delay', 2);
        alertify.set('notifier','position', 'top-right');
        alertify.error('Error message');
    }
    readRecords();
    $('#form1').trigger("reset");
}
 
     
    