如何下载MP4文件而不是在浏览器上播放? [英] How can I download a MP4 file instead of playing it on browser?

查看:657
本文介绍了如何下载MP4文件而不是在浏览器上播放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我点击锚标签时,我需要将一个.mp4文件下载到我的系统。

I have a .mp4 file that I need to download to my system when I click on the anchor tag.

HTML:

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

有没有办法下载这个而不是在浏览器中打开它?

Is there any way to download this instead of opening it in a browser?

我也需要这个在IE上运行,我唯一的选择是通过javascript或jQuery。还可以建议任何其他更简单的东西。

I needed this to run on IE as well and the only option I have is through javascript or jQuery. Anything else that is simpler can also be suggested.

我知道HTML5 下载属性,但它没有在IE上支持。

I am aware of the HTML5 download attribute, but it doesn't support on IE.

推荐答案

我发现了这个: http://www.webdeveloper.com/forum/showthread.php?244007-已解决 - 强制下载MP3文件而不是流式传输并且我使用Excel文件执行类似操作。

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.

直接从那里:

使用一个小的PHP文件来处理下载,放在与.mp3相同的文件夹中:

use a small PHP file to handle the download, put in the same folder as the .mp3:

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

可以在任何锚点访问:

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

这篇关于如何下载MP4文件而不是在浏览器上播放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆