如何实现Content

编程入门 行业动态 更新时间:2024-10-11 23:24:32
本文介绍了如何实现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

本文发布于:2023-10-10 09:24:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1478289.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何实现   Content

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!