【发布时间】:2020-11-18 12:02:09
【问题描述】:
我正在尝试寻找一种解决方案,以强制使用 PHP 在移动设备上下载音频文件。
我尝试在我的 .htaccess 文件中使用 MIME 类型“AddType audio/mpeg .mp3”没有效果。直接下载在台式机上运行良好,但在移动设备上却不行 - 它总是重定向到默认的 Wordpress 播放器进行下载,而不是在单击链接后才下载。
我已经搜索了各种解决方案,这是我得到的壁橱Forcing to download a file using PHP
我的文件托管在我的域之外。这是我正在使用的 PHP 文件,但它不起作用。
$file_name = 'file.mp3';
$file_url = 'https://mcdn.podbean.com/mf/web/' . $file_name;
header('Content-Type: audio/mpeg');
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename="my-file.mp3");
readfile($file_url);
exit;
【问题讨论】:
标签: audio mobile mp3 mime-types mime