简体   繁体   中英

How to make an mp3 file from another site downloadable

I almost feel ashamed to ask such a basic question, what with how i like to term my self a website genius when with friends this seems quite basic.

I'm trying to get visitors to my site to download an mp3 link=> " http://www.podbean.com/podcast-directory-download-public/4995714/10_Commandments_Of_A_Successful_Home_Pst_Abiodun_Koloewo.mp3 ". But the problem i'm facing is that it won't download unless one right clicks and selects "save link as" and i can't do anything about it since the file's not on my server. any help here?

You have two methods, one of which only works in Chrome.

Use the download attribute:

Though this is used in Firefox, it states: In Firefox 20 this attribute is only honored for links to resources with the same-origin. so it doesn't work.

Example:

<a href="http://www.podbean.com/podcast-directory-download-public/4995714/10_Commandments_Of_A_Successful_Home_Pst_Abiodun_Koloewo.mp3" download>Download Song</a>

Use your server as a proxy:

Example:

header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary"); 
header("Content-disposition: attachment;filename=\"10_Commandments_Of_A_Successful_Home_Pst_Abiodun_Koloewo.mp3\"");
readfile("http://www.podbean.com/podcast-directory-download-public/4995714/10_Commandments_Of_A_Successful_Home_Pst_Abiodun_Koloewo.mp3");

For this example to work, please enable allow_url_fopen .

In addition to this, I would recommend saving the song file on your server, so that new requests for this song can just be downloaded from your server again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM