I'm trying to find a solution for forcing audio files to download on mobile using PHP.
I tried using the MIME type 'AddType audio/mpeg .mp3' in my .htaccess file to no effect. Direct downloads work fine on desktop but not on mobile - it always redirects to the default Wordpress player to download instead of just downloading after clicking the link.
I've searched various solutions and this is the closet I got Forcing to download a file using PHP
My files are hosted outside of my domain. This is the PHP file I'm using but it's not working.
$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;