<?php
session_start(); // Start the session

// Check if the video_name field is set in the POST request
if(isset($_POST["video_name"])) {
    $username = $_SESSION['username'];
    $rolemaster_id = $_SESSION['rolemaster_id'];

    require("connect.php");

    $videoName = $_POST["video_name"];
    $targetDir = "/wamp62/www/rythm/videos/";

    // Move the uploaded video file to the target directory
    $targetFilePath = $targetDir . $videoName;
    $tempFilePath = $_FILES["upload_file"]["tmp_name"]; // Temporary file path of the uploaded video
    
    if(move_uploaded_file($tempFilePath, $targetFilePath)) {
        // File was successfully uploaded and moved
        echo "Video file successfully uploaded to: " . $targetFilePath;
    } else {
        // Failed to move the file
        echo "Error uploading video file.";
    }
} else {
    echo "Video name field is not set.";
}
?>
