【问题标题】:how can i force for download a video from url?如何强制从 url 下载视频?
【发布时间】:2018-12-23 15:32:30
【问题描述】:

如何强制从 url 下载 mp4 文件?

url = "https://clips-media-assets2.twitch.tv/AT-cm%7C31747331920-offset-17408-720.mp4"

我试过这段代码,但它不起作用

header('Content-Type: video/mp4');
header("Content-Transfer-Encoding: Binary"); 
header("Content-disposition: attachment; filename=\"".$file_name."\"");
echo file_get_contents($links); 

【问题讨论】:

标签: php twitch


【解决方案1】:

如果您在服务器中使用外部链接,则必须小心。仅将此代码用于您的服务器文件。

<?php
header('Content-Type: application/octet-stream');
header('Content-Transfer-Encoding: Binary'); 
header('Content-disposition: attachment; filename="video.mp4"'); 
readfile('/video/offset-17408-720.mp4'); 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-12-04
    • 2019-10-28
    • 2019-02-22
    • 1970-01-01
    • 2017-05-30
    • 2011-07-11
    • 2018-06-10
    • 2015-09-06
    相关资源
    最近更新 更多