HTML code that allows the user to download an mp3

Posted on 2011-04-20
Last Modified: 2012-05-11
how do I write code that will enable the user to download the actual mp3, as opposed to the code below which just plays it?

<div align="center"><a href="http://www.mysitecom/Songs/MySong.mp3">Download mp3</a></div>

Open in new window

Question by:gabrielPennyback
    LVL 13

    Expert Comment

    There isn't an easy answer to this. You cant do it with just some HTML. You would need some PHP or edit the .htaccess file.

    I can give you instruction on this, though it doesn't work on older browsers.

    The simplest way would be to either zip up the mp3 prior to upload, so it is a .zip file. This will download, though the end user will have to extract it before use.

    Also, you can put in some type of instruction that says "right click and select save as".

    Would you like further instruction on any of those?
    LVL 82

    Expert Comment

    by:Dave Baldwin
    The user can Right Click and select "Save Page As" to download the file.  You can mention that on that page.  The only reason it plays is because someone has an application designated to play it.  If they don't, the browser would ask if they want to download it.
    LVL 1

    Author Comment


    Hi jonahzona, yes i would love instructions on how to do this with PHP. Thanks. Dave, I hear what you're saying but the problem is that everybody has something that will play mp3's automatically.

    - John
    LVL 13

    Accepted Solution

    Here is a full description on how to accomplish this.
    LVL 1

    Author Closing Comment


    - John

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    "I want to put my photos online, but I don't want them stolen.  What settings should I use?" When You Put Photos Online First and foremost, any digital file published on the WWW can be copied, stored, modified, retransmitted, etc.  Remember Naps…
    Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
    In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
    In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now