本文介绍了如何实现Content-Disposition:附件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在努力让我的网站上的mp3通过左键点击下载,而不必右键单击并保存为,所以为了做到这一点,我必须设置Content-Disposition:附件。这是我的第一个网站,所以我对如何实际做到这一点很陌生,但是我在我的html标记中这样做,还是以某种方式设置了我的托管站点?
I am trying to make it so that mp3's on my site are downloaded by left clicking instead of having to right click and save as, So in order to do that, I have to set the Content-Disposition: attachment. This is my first website so I am new to how to actually do this, but do I do this in my html markup or do I set this somehow with my hosting site?
以下是我的标记看起来像的一个例子。
Here is an example of what my markup looks like.
<div class="download"> <a href="MP3/Morgan Page, Sultan & Ned Shepard, and BT feat. Angela McCluskey.mp3" <img src="img/dlicon.png"/></a> </div>推荐答案
MP3列表示例:
<a href="download.php?file=testing.mp3">Download MP3</a> <a href="download.php?file=testing2.mp3">Download MP3</a>download.php:
download.php :
<?php $file = $_GET['file']; header('Content-type: audio/mpeg'); header('Content-Disposition: attachment; filename="'.$file.'"'); ?>更多推荐
如何实现Content
发布评论