i dont know php & i want a script that when a user click on a mp3 hyperlink, the mp3 file start downloading instead of start playing in media player.
i got a sxript from internet search.
i am using the following code
[code=php]
<?php
$filename = "path/to/file/filname.ext";
if(!file_exists ($filename)) {
die("File does not exist!");
}
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false) ;
header("Content-Disposition: attachment; filename=\"".ba sename($filenam e)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Type: PHP Generated Data");
header("Content-Length: ".filesize($fil ename));
readfile("$file name");
exit();
?>
[/code]
i have saved this code with name download.php
every time code give error message that "File does not exist!"
i have uploaded the download.php file in the same directory where the mp3 file is uploaded and i am using the folliwing hyper link code in the html file
[code=html]
<a target="_blank" href="download. php?location=AB C.mp3">downlaod ABC</a>[/code]
index.html, download.php and ABC.mp3 are in the same directory
in IE-7 it start downloading file with the name i specified in the code, but with size 27bytes, abd after opening this file in notepad i get the error "File does not exist!". BUT in Mozilla firefox it give same erroe message in a new window.
can anyone tell me what is the problem???????
Thanx
i got a sxript from internet search.
i am using the following code
[code=php]
<?php
$filename = "path/to/file/filname.ext";
if(!file_exists ($filename)) {
die("File does not exist!");
}
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false) ;
header("Content-Disposition: attachment; filename=\"".ba sename($filenam e)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Type: PHP Generated Data");
header("Content-Length: ".filesize($fil ename));
readfile("$file name");
exit();
?>
[/code]
i have saved this code with name download.php
every time code give error message that "File does not exist!"
i have uploaded the download.php file in the same directory where the mp3 file is uploaded and i am using the folliwing hyper link code in the html file
[code=html]
<a target="_blank" href="download. php?location=AB C.mp3">downlaod ABC</a>[/code]
index.html, download.php and ABC.mp3 are in the same directory
in IE-7 it start downloading file with the name i specified in the code, but with size 27bytes, abd after opening this file in notepad i get the error "File does not exist!". BUT in Mozilla firefox it give same erroe message in a new window.
can anyone tell me what is the problem???????
Thanx
Comment