下载mp3文件而不是脚本 [英] Download mp3 File Not Script
本文介绍了下载mp3文件而不是脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我单击网页时,我在网页上有一个图像,它应该下载mp3,而不是下载mp3.php脚本文件,我如何获得它来下载文件?这是脚本,其后是页面上的内容.
I have an image on a web page when you click on it, it''s suppose to download an mp3, instead it''s downloading the mp3.php script file, how can I get it to download the file? Here is the script followed by whats on the page.
$mp3 = $_GET['mp3'];
$file = '/Tunedoggie/Songs/'.$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>");
}
?>
</p>
<p><a href="mp3.php?mp3=Oh No No.mp3"><img src="Dan.jpg" border ="0" alt="Alt Tag Goes Here"></a></p>
推荐答案
mp3 =
mp3 =
_GET [ ' mp3'];
_GET['mp3'];
文件 = '
这篇关于下载mp3文件而不是脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文