Tracking mp3 downloads
Posted: Wed Dec 13, 2006 4:53 pm
I've written a script that retrieves details about mp3's from a database and outputs them as a table showing relevant info, a link to play it and how many times it downloads.
The link to play it updates the database and then outputs the mp3 - I want people to open or save it, so the code for that I used is...
where $filename is the retrieved filename - that is tested.
What happens is that only 225-243bytes are output rather 9MB!
If I use just
it plays the mp3 straight away. http://www.thebridgechurch.co.uk/index.php?pageid=14
Why does readfile truncate themp3? And how can i get it to work so the file can be opened or saved?
The link to play it updates the database and then outputs the mp3 - I want people to open or save it, so the code for that I used is...
Code: Select all
header('Content-type: audio/mpeg');
header("Content-Disposition: attachment; filename='$filename'");
readfile("Location:http://www.thebridgechurch.co.uk/sermons/$filename");What happens is that only 225-243bytes are output rather 9MB!
If I use just
Code: Select all
header("Location:http://www.thebridgechurch.co.uk/sermons/$filename");Why does readfile truncate themp3? And how can i get it to work so the file can be opened or saved?