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?
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.
I am aware of the HTML5 download
attribute, but it doesn't support on IE.
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?
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.
I am aware of the HTML5 download
attribute, but it doesn't support on IE.
3 Answers
Reset to default 3I found this: http://www.webdeveloper./forum/showthread.php?244007-RESOLVED-Force-download-of-MP3-file-instead-of-streaming and I do similar things with Excel files.
Directly from there:
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;
?>
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.
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.
If you are able to write an .htaccess
or edit the Apache config, you can also check this proposed response to force a download.