Jea*_*les 14 html php content-disposition
我试图通过左键单击下载而不是右键单击并保存为我的网站上的mp3,所以为了做到这一点,我必须设置Content-Disposition:attachment.这是我的第一个网站,所以我是如何实际做到这一点的新手,但我是否在我的html标记中这样做,或者我是否以某种方式设置了我的托管网站?
这是我的标记看起来像的一个例子.
<div class="download">
<a href="MP3/Morgan Page, Sultan & Ned Shepard, and BT feat. Angela McCluskey.mp3"
<img src="img/dlicon.png"/></a>
</div>
Run Code Online (Sandbox Code Playgroud)
Zul*_*rul 22
MP3列表示例:
<a href="download.php?file=testing.mp3">Download MP3</a>
<a href="download.php?file=testing2.mp3">Download MP3</a>
Run Code Online (Sandbox Code Playgroud)
download.php:
<?php
$file = $_GET['file'];
header('Content-type: audio/mpeg');
header('Content-Disposition: attachment; filename="'.$file.'"');
?>
Run Code Online (Sandbox Code Playgroud)