I want to force the user tho download a youtube video. For example this url. I download the video and I can play the original video, but even the length/size of video is the same I cant play it when is force_downloaded.
function force_download($file,$video_url)
{
$video_data = file_get_contents($video_url);
file_put_contents($file, $video_data);
if(isset($file) && file_exists($file))
{
header('Content-length: ' . filesize($file));
header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename= "' . $file . '"');
readfile($file);
}
}
force_download('youtube.mp4',$video_url);