Javascript File Download

Hey everyone,

What I want to do is create a link like this:

<a href="javascript:download('audio.mp3')">Download</a>

With the function triggering a file download. Is it possible to do something like that in javascript? What would that function look like?


I can only assume you would want:

function download(file) {
window.location = file;

A better way to achieve the same thing would be:

<a href=“audio.mp3”>Download</a>

neither solution actually triggers the file download, however… just functions as a link to the file. i actually accomplished what i wanted with a modified version of this PHP script:

in case anybody else is interested :slight_smile: