简体   繁体   English

如何下载MP4文件而不是在浏览器上播放?

[英]How can I download a MP4 file instead of playing it on browser?

I have a .mp4 file that I need to download to my system when I click on the anchor tag. 我有一个.mp4文件,当我点击锚标签时,我需要将其下载到我的系统。

HTML: HTML:

<a href="DSCSA_webinar.mp4">Download Here</a>

Is there any way to download this instead of opening it in a browser? 有没有办法下载这个而不是在浏览器中打开它?

I needed this to run on IE as well and the only option I have is through javascript or jQuery. 我需要这个在IE上运行,我唯一的选择是通过javascript或jQuery。 Anything else that is simpler can also be suggested. 还可以建议任何其他更简单的东西。

I am aware of the HTML5 download attribute, but it doesn't support on IE. 我知道HTML5 download属性,但它不支持IE。

I found this: http://www.webdeveloper.com/forum/showthread.php?244007-RESOLVED-Force-download-of-MP3-file-instead-of-streaming and I do similar things with Excel files. 我发现了这个: http//www.webdeveloper.com/forum/showthread.php ?244007-RESOLVED-Force-download-of-MP3-file-instead-of- streaming ,我用Excel文件做类似的事情。

Directly from there: 直接从那里:

use a small PHP file to handle the download, put in the same folder as the .mp3: 使用一个小的PHP文件来处理下载,放在与.mp3相同的文件夹中:

<?php
$file = $_GET['file'];
header ("Content-type: octet/stream");
header ("Content-disposition: attachment; filename=".$file.";");
header("Content-Length: ".filesize($file));
readfile($file);
exit;
?>

which can be accessed in any anchor like this: 可以在任何锚点访问,如下所示:

<a href="direct_download.php?file=fineline.mp3">Download the mp3</a>

I've run into this with video files (I want to offer a download, but the browser always tries to open it). 我用视频文件遇到了这个问题(我想提供下载,但浏览器总是尝试打开它)。

If you can't use a server-side language like dgig mentions, the only thing I've been able to do is put the file in a ZIP file and let the user download that. 如果您不能使用dgig提及的服务器端语言,我唯一能做的就是将文件放在ZIP文件中,让用户下载。

Apple does this with Quicktime samples, and since they have more money and resources to throw at this than I do, I figured that was probably how I'd have to do it. Apple使用Quicktime样本做到了这一点,因为他们有更多的资金和资源可以投入,我认为这可能是我必须要做的。

如果您能够编写.htaccess或编辑Apache配置,您还可以检查此建议的响应以强制下载。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 node.js 下载视频 mp4 文件? - how can i download a video mp4 file using node.js? 如何从 https 链接下载 MP4 文件并在 Node.js 中重定向? - How can I download MP4 file from https link with redirect in Node.js? 我可以使用web下载m3u8文件的所有片段作为一个mp4文件(没有ffmpeg) - Can I download all segments of a m3u8 file as one mp4 file using web ( no ffmpeg ) 下载.mp3文件而不是在Firefox或Chrome中播放它们? - Download .mp3 file instead of playing them in firefox or chrome? 强制 MP3 文件充当“另存为...”而不是在浏览器中播放 - Force MP3 file to act as “Save as…” instead of playing in the browser 只有一个简单的html和js文件,我怎么能强制链接到MP3下载而不是只是播放? - with just a plain html and js file, how can i force a link to an mp3 to download instead of just play? 强制下载指向MP4文件的链接,而不是使用Meteor.js在浏览器中取消链接 - Force links to MP4 files to download instead of opeaning in browser using Meteor.js 如何检测 URL 是 mp4 还是 m3u8 并在浏览器上播放? - How can I detect the URL is mp4 or m3u8 and play it on browser? Chrome无法下载,但其他浏览器可以…mp4上的html链接 - Chrome can't download but other browser can … html link on mp4 Node.js将html启动到localhost:8000,如何在该html文件中调用.mp3 / .mp4文件 - Node.js launches html to localhost:8000, how can I call a .mp3/.mp4 file in that html file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM