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

How to make an mp3 file from another site downloadable

本文关键字:下载 mp3 文件 网站 其他      更新时间:2023-09-26

我几乎为问这样一个基本的问题而感到羞愧,当我和朋友在一起时,我喜欢把自己称为网站天才,这似乎很基本。

我正试图让访问者到我的网站下载mp3链接=>"http://www.podbean.com/podcast-directory-download-public/4995714/10_Commandments_Of_A_Successful_Home_Pst_Abiodun_Koloewo.mp3"。但我面临的问题是,除非右键单击并选择"将链接另存为",否则它不会下载。由于文件不在我的服务器上,我对此无能为力。这里有什么帮助吗?

您有两个方法,其中一个仅适用于Chrome。

使用下载属性:

虽然这在Firefox中使用,但它声明:In Firefox 20 this attribute is only honored for links to resources with the same-origin.,所以它不起作用

示例:

<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>

将服务器用作代理:

示例:

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");

要使此示例工作,请启用allow_url_fopen

除此之外,我建议将歌曲文件保存在您的服务器上,这样就可以再次从您的服务器下载对这首歌曲的新请求。