您有两种方法,其中一种仅适用于 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
.
除此之外,我建议将歌曲文件保存在您的服务器上,以便可以再次从您的服务器下载对这首歌的新请求。