简体   繁体   English

如何从其他站点下载mp3文件

[英]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 ". 我试图吸引访问者到我的站点下载mp3链接=>“ 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. 您有两种方法,其中一种仅适用于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. 尽管在Firefox中使用了In Firefox 20 this attribute is only honored for links to resources with the same-origin. ,但它指出: 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 . 为了使该示例正常工作,请启用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. 除此之外,我建议将歌曲文件保存在服务器上,以便可以再次从服务器下载对此歌曲的新请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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