Being a new coder I keep doing a lot of trial and errors and stick with the finds that work, how ever the method I have at the moment does not work with all browsers.
Our PHP code.
$songs = file_get_contents('https://example.com/tracks/'.$id.'/');
$filename = './tmp/'.$SongTitle.'.mp3'; // used for the file_put_contents.
$filenames = '/tmp/'.$SongTitle.'.mp3'; // used for the echo
file_put_contents($filename, $songs);
HTML Download Button.
<div style="text-align: center; font-size: 20px;" class="testing-content">
<button type="button" class="btn btn-success"><a href="<?php echo $filenames; ?>" download='<?php echo $filenames; ?>' href="javascript:">Download</button></a>
</div>
You can see that I am using the Html5 and the Javascript method above meaning it only has support on FireFox and Google Chrome.
How can I allow users on all browsers to download the file on click of our button?