Search code examples
audiohyperlinkmp3download

Link to force download of MP3 files to default downloads folder


I have some MP3 files in a playlist each of which has a link next to it in the form:

<a href="/music/track1.mp3"></a>

The user can right click on the link and choose 'download linked file' (or equivalent option in browser).

What I would like is for files to download automatically when users click on the links (i.e. a standard left click) and not via the "Save As" dialogue, but to the users default download folder for their browser.

What would be the simplest way of achieving this?


Solution

  • You need to configure your webserver to add Content-Disposition attachment to the HTTP header. Here are instructions on how to do that with Apache.

    As Mitch Satchwell said, you can also do this with server-side languages, that operate on a low-enough level so you can modify the HTTP header.