How to make the user download the video instead of playing it when opening the video address
How to make the user download the video instead of playing it when opening the video address
Use PHP to proxy downloads
<code><?php $file = "/tmp/视频.mp4"; $filename = basename($file); header("Content-type: application/octet-stream"); //处理中文文件名 $ua = $_SERVER["HTTP_USER_AGENT"]; $encoded_filename = rawurlencode($filename); if (preg_match("/MSIE/", $ua)) { header('Content-Disposition: attachment; filename="' . $encoded_filename . '"'); } else if (preg_match("/Firefox/", $ua)) { header("Content-Disposition: attachment; filename*=\"utf8''" . $filename . '"'); } else { header('Content-Disposition: attachment; filename="' . $filename . '"'); } header("Content-Length: ". filesize($file)); readfile($file);</code>
Quoted Brother Bird’s code: http://www.laruence.com/2012/...
a Tag H5 has a new attribute download, which allows the browser to download the file connection by default and specify the download file name. However, there are compatibility issues, you can try
Link description