HTML download movie download link

喜夏-厌秋 提交于 2019-12-11 04:07:58

问题


I want a user to be able to hit a button which triggers a .mov file to download. Linking to the file its self just causes the movie to play in a new page.

I have tried this:

<a onclick="document.execCommand('SaveAs',true,'assets/files/mymovie.mov');" href="javascript:void(0);">

But this does not seem to work.

Can anyone point me in the right direction?

Thanks


回答1:


You can try the html5 download attribute.

<a href='assets/files/mymovie.mov' download>



回答2:


In addition to Musa's answer:

Try setting the Content-Disposition header. You will need to set this up either in your server configuration, or let a executable script on your server do this (such as php):

Content-Disposition: attachment; filename="mymovie.mov"



回答3:


if you're using a server side page to serve up content, by chance, then you can easily set the header of that page Content-Disposition: attachment and/or Content-Type:binary so that it kicks off a download.

otherwise, you can use download attribute in your <a> tag, which will only work in some browsers.

lastly, if you're feeling really heroic, you can go hack on your mime-types settings config file in your web server, in which you'd set the content disposition there.



来源:https://stackoverflow.com/questions/12313082/html-download-movie-download-link

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!