How can PHP be used to deliver video content securely without allowing downloads?

To deliver video content securely without allowing downloads, you can use PHP to stream the video content directly to the user's browser without revealing the direct URL of the video file. By using PHP to control access to the video file and streaming it in chunks, you can prevent users from downloading the video file directly.

<?php
// Check if user is authenticated and authorized to access the video
if($authenticated && $authorized) {
    $videoPath = 'path/to/video/video.mp4';

    // Set appropriate headers for streaming video content
    header("Content-Type: video/mp4");
    header("Content-Length: " . filesize($videoPath));

    // Open the video file and stream it to the browser in chunks
    $file = fopen($videoPath, "rb");
    while(!feof($file)) {
        echo fread($file, 8192);
        ob_flush();
        flush();
    }
    fclose($file);
} else {
    // Handle unauthorized access
    header("HTTP/1.1 403 Forbidden");
    echo "You are not authorized to access this content.";
}
?>