<?php

if (isset($_POST["id"])) {
    include("../connectSQL_Component.php");


    $sql = "SELECT * FROM [BIMComponents].[dbo].[Video_Table] WHERE [id] = '" . $_POST["id"] . "'";
    $fetchResult = sqlsrv_query($conn, $sql);
    $file_name = "";
    $file_path = "";
    $title = "";
    while ($row = sqlsrv_fetch_array($fetchResult)) {
        $file_name = $row["file_name"];
        $file_path = $row["file_path"];
        $title = $row["title"];
    }
    $token = "../../." . $file_path;
    sqlsrv_close($conn);
    if (file_exists($token)) {
        echo $file_path;;
    } else {
        echo "Error: File Does not exists";
    }
}
