Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用于流式传输wmv视频文件的PHP标头_Php_Header_Video Streaming_Wmv - Fatal编程技术网

用于流式传输wmv视频文件的PHP标头

用于流式传输wmv视频文件的PHP标头,php,header,video-streaming,wmv,Php,Header,Video Streaming,Wmv,当我直接指向它在浏览器中播放的文件时,但是如果我试图通过PHP播放它,它就不起作用了。我的代码是: <?php $file = 'videos/video.wmv'; $file_name = 'video.wmv'; $file_type = 'video/x-ms-wmv'; header('Content-Description: File Transfer'); header('Content-Disposition: filename="'.$file_name.'"'); h

当我直接指向它在浏览器中播放的文件时,但是如果我试图通过PHP播放它,它就不起作用了。我的代码是:

<?php
$file = 'videos/video.wmv';
$file_name = 'video.wmv';
$file_type = 'video/x-ms-wmv';

header('Content-Description: File Transfer');
header('Content-Disposition: filename="'.$file_name.'"');
header('Content-Type: '.$file_type);
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file));
header('Cache-Control: post-check=0, pre-check=0');
header('Pragma: public');
header("Accept-Ranges: bytes");
header('Expires: 0');
readfile($file);
?>

它适用于PDF、rar和zip文件,但不适用于流式视频。WMP窗口出现,但视频不播放


感谢您的帮助。

旁注:您声称接受范围,但您显示的代码实际上不具备处理范围请求的能力。。。不管是哪种方式,为什么首先要通过PHP传递呢?您不能直接通过web服务器提供服务吗?web服务器对资源友好得多。在打印文件之前,我将在数据库中编写一个用户验证。这正是我需要的。是的,它下载其他文件很好。