只有一个纯html和js文件,我怎么能强制链接到一个MP3下载,而不是只是玩? [英] with just a plain html and js file, how can i force a link to an mp3 to download instead of just play?
问题描述
我有一个媒体文件(如mp3)的链接,我希望在用户点击它时下载它,而不仅仅是让文件播放。我想到的页面只是一个普通的静态html页面。
有什么想法?
Content-disposition:attachment;文件名= fname.ext
在发送文件之前用你喜欢的语言标题。 不知道具体内容,例如您的服务器配置使用哪种语言和哪种控制方式,我无法给您更详细的说明。不过,只能使用html和javascript来完成。
i have a link to a media file such as an mp3, and i want it to get downloaded when the user clicks on it, instead of just having the file get played. the page i have in mind is just a plain static html page.
any ideas?
In order to make that happen you need to send a header with Content-disposition: attachment; filename=fname.ext
header in your favorite language before sending the file.
Without knowing the specifics such as what language and what control you have over your server configuration I cannot give you more detailed instructions. You cannot do it with just html and javascript however.
这篇关于只有一个纯html和js文件,我怎么能强制链接到一个MP3下载,而不是只是玩?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!