在我的程序中,我想添加一个下载选项来下载当前播放的视频。我试过这段代码:
$psp = "Tom_20_amp__20Jerry_20race-1.flv";
header("Content-type:application/octet-stream");
header("Content-Disposition:attachment;filename=$psp");
但是我得到这个错误:
"C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\Tom_20_amp__20Jerry_20race-1-5.flv" is not a valid FLV file.
视频流正常。请指导我
最佳答案
改变你的标题:
header("Content-type:application/octet-stream");
收件人:
header("Content-type: video/flv");
然后你可以这样做:
header("Content-Disposition:attachment;filename=\"$psp\"");
//allways a good idea to let the browser know how much data to expect
header("Content-length: " . filesize($psp) . "\n\n");
echo file_get_contents($psp); //$psp should contain the full path to the video
关于php - 如何使用php脚本下载视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4624012/