Paste this code below into notepad and save as mp3.php - where you see
$file = '
/home/mp3/'.$mp3;
change the red bit to be the filename path of where your mp3 files are kept. Save this in your main directory online.
<?php
$mp3 = $_GET['mp3'];
$file = '/home/mp3/'.$mp3;
if(ini_get('zlib.output_compression')) {
ini_set('zlib.output_compression', 'Off');
}
if ( file_exists($file) ) {
header("Pragma: public");
header('Expires: '.gmdate('D, d M Y H:i:s').' GMT');
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Type: application/mp3");
header('Content-Disposition: attachment; filename="'.$mp3.'"');
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".@filesize($file));
set_time_limit(0);
@readfile($file) OR die("<html><body OnLoad="javascript: alert('Unable to read file!');history.back();" bgcolor="#F0F0F0"></body></html>");
exit;
} else {
die("<html><body OnLoad="javascript: alert('File not found!');history.back();" bgcolor="#F0F0F0"></body></html>");
}
?>
- <?php
- $mp3 = $_GET['mp3'];
- $file = '/home/mp3/'.$mp3;
- if(ini_get('zlib.output_compression')) {
- ini_set('zlib.output_compression', 'Off');
- }
- if ( file_exists($file) ) {
- header("Pragma: public");
- header('Expires: '.gmdate('D, d M Y H:i:s').' GMT');
- header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
- header("Cache-Control: private",false);
- header("Content-Type: application/mp3");
- header('Content-Disposition: attachment; filename="'.$mp3.'"');
- header("Content-Transfer-Encoding: binary");
- header("Content-Length: ".@filesize($file));
- set_time_limit(0);
- @readfile($file) OR die("<html><body OnLoad="javascript: alert('Unable to read file!');history.back();" bgcolor="#F0F0F0"></body></html>");
- exit;
- } else {
- die("<html><body OnLoad="javascript: alert('File not found!');history.back();" bgcolor="#F0F0F0"></body></html>");
- }
- ?>
Then in your webpage where you want the download links to be you write your link code like this, where you see the
FileName.mp3insert your filename. Where you see the
images/graphic.gifinsert your graphic image for your button you want them to press to download the song file.
<a href="mp3.php?mp3=FileName.mp3"><img src="images/graphic.gif" border ="0" alt="Alt Tag Goes Here"></a>
What you will end up with is a graphic button, when pressed will bring up a dialog box which asks them what they want to do with the file (Open with or Save to disc).
Hope that helps and good luck with your music!

I put it in my main directory (as well as my root and another one just to be sure). I pasted the other short snippet of code into the page that i wanted it to show up on (with the changes) and i get, "can't find file".
I know the path is correct. Can't figure it out.