Awesomestvi
Awesomestvi

Reputation: 803

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.

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.

Upvotes: 3

Views: 11746

Answers (3)

P. Mergey
P. Mergey

Reputation: 343

If you are able to write an .htaccess or edit the Apache config, you can also check this proposed response to force a download.

Upvotes: 0

Tim
Tim

Reputation: 4101

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.

Upvotes: 1

dmgig
dmgig

Reputation: 4568

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.

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>

Upvotes: 3

Related Questions