Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
525 views
Welcome To Ask or Share your Answers For Others

1 Answer

Example of MP3 Lists:

<a href="download.php?file=testing.mp3">Download MP3</a>
<a href="download.php?file=testing2.mp3">Download MP3</a>

download.php :

<?php

$file = $_GET['file'];  

header('Content-type: audio/mpeg');

header('Content-Disposition: attachment; filename="'.$file.'"');

?>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...