使用php程序下载视频文件?

gearss00 2016-07-01 08:11:05
我想使用php程序下载http://116.199.115.230/recplay2/vod/vods/20160624/gztv_tv_rtmp20160624065630_1.mp4这个文件,我用的是file_get_contents()这个函数,但是不行。请问如何才能成功下载这个文件?
...全文
605 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuzuning 2016-07-01
  • 打赏
  • 举报
回复
三百多兆?应该是太大了,超出了可用内存而中断了,或是说因为看到 http 头中指示的数据长度太大而终止了执行 可用 curl 并设置 CURLOPT_FILE 属性,直接保存到文件
$url = 'http://116.199.115.230/recplay2/vod/vods/20160624/gztv_tv_rtmp20160624065630_1.mp4';
$fp = fopen("test.mp4", "wb");
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec($ch);
  • 打赏
  • 举报
回复
文件太大了

$filename = 'http://116.199.115.230/recplay2/vod/vods/20160624/gztv_tv_rtmp20160624065630_1.mp4';
//文件的类型
header('Content-type: application/mpeg4');
//下载显示的名字
header('Content-Disposition: attachment; filename="3.mp4"');
readfile("$filename");
exit(); 

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧