如何从浏览器的右键菜单中禁用“另存为…”以防止客户端下载视频?
是否有更完整的解决方案来阻止客户端直接访问文件路径?
如何从浏览器的右键菜单中禁用“另存为…”以防止客户端下载视频?
是否有更完整的解决方案来阻止客户端直接访问文件路径?
当前回答
是的,你可以通过三个步骤做到这一点:
将要保护的文件放置在运行代码的目录的子目录中。 www.foo.com/player.html www.foo.com/videos/video.mp4 在该子目录中保存一个名为“”的文件。并添加下面的行。 www.foo.com/videos/.htaccess # .htaccess的内容 RewriteEngine上 RewriteCond % {HTTP_REFERER} ! ^ http://foo.com/。* $(数控) ^http://www.foo.com/.*$ [NC] 重写规则(mp4|mp3|avi)$ - [F]
现在源链接是无用的,但我们仍然需要确保任何试图下载该文件的用户不能直接获得该文件。
对于一个更完整的解决方案,现在为视频提供一个flash播放器(或html画布),不要直接链接到视频。只需删除右键菜单,添加到您的HTML: <body oncontextmenu="return false;">
结果:
www.foo.com/player.html可以正确播放视频,但如果你访问www.foo.com/videos/video.mp4:
错误代码403:禁止
这将工作直接下载,cURL,盗链,你的名字。
这是对两个问题的完整回答,而不是对“我能否阻止用户下载他们已经下载的视频”这个问题的回答。
其他回答
是的,你可以通过三个步骤做到这一点:
将要保护的文件放置在运行代码的目录的子目录中。 www.foo.com/player.html www.foo.com/videos/video.mp4 在该子目录中保存一个名为“”的文件。并添加下面的行。 www.foo.com/videos/.htaccess # .htaccess的内容 RewriteEngine上 RewriteCond % {HTTP_REFERER} ! ^ http://foo.com/。* $(数控) ^http://www.foo.com/.*$ [NC] 重写规则(mp4|mp3|avi)$ - [F]
现在源链接是无用的,但我们仍然需要确保任何试图下载该文件的用户不能直接获得该文件。
对于一个更完整的解决方案,现在为视频提供一个flash播放器(或html画布),不要直接链接到视频。只需删除右键菜单,添加到您的HTML: <body oncontextmenu="return false;">
结果:
www.foo.com/player.html可以正确播放视频,但如果你访问www.foo.com/videos/video.mp4:
错误代码403:禁止
这将工作直接下载,cURL,盗链,你的名字。
这是对两个问题的完整回答,而不是对“我能否阻止用户下载他们已经下载的视频”这个问题的回答。
尝试禁用下载视频选项
<video src="" controls controlsList="nodownload"></video>
如果你正在寻找一个完整的解决方案/插件,我发现这个非常有用 https://github.com/mediaelement/mediaelement
使用Vimeo等服务:登录Vimeo > Goto Video >设置>隐私>标记为安全,也可以选择嵌入域。一旦设置了嵌入域,它将不允许任何人嵌入视频或从浏览器显示它,除非从指定的域连接。所以,如果你有一个页面在你的服务器上是安全的,它在iframe中加载Vimeo播放器,这使得它很难绕过。
简单回答:像youtube那样加密链接,不知道怎么做,不如问问youtube/谷歌他们是怎么做的。(以防你想直奔主题。)
I would like to point out to anyone that this is possible because youtube does it and if they can so can any other website and it isn't from the browser either because I tested it on a couple browsers such as microsoft edge and internet explorer and so there is a way to disable it and seen that people still say it...I tries looking for an answer because if youtube can than there has to be a way and the only way to see how they do it is if someone looked into the scripts of youtube which I am doing now. I also checked to see if it was a custom context menu as well and it isn't because the context menu is over flowing the inspect element and I mean like it is over it and I looked and it never creates a new class and also it is impossible to actually access inspect element with javascript so it can't be. You can tell when it double right-click a youtube video that it pops up the context menu for chrome. Besides...youtube wouldn't add that function in. I am doing research and looking through the source of youtube so I will be back if I find the answer...if anyone says you can't than, well they didn't do research like I have. The only way to download youtube videos is through a video download.
Okay...I did research and my research stays that you can disable it except there is no javascript to it...you have to be able to encrypt the links to the video for you to be able to disable it because I think any browser won't show it if it can't find it and when I opened a youtube video link it showed as this "blob:https://www.youtube.com/e5c4808e-297e-451f-80da-3e838caa1275" without quotes so it is encrypting it so it cannot be saved...you need to know php for that but like the answer you picked out of making it harder, youtube makes it the hardest of heavy encrypting it, you need to be an advance php programmer but if you don't know that than take the person you picked as best answer of making it hard to download it...but if you know php than heavy encrypt the video link so it only is able to be read on yours...I don't know how to explain how they do it but they did and there is a way. The way youtube Encrypts there videos is quite smart so if you want to know how to than just ask youtube/google of how they do it...hope this helps for you although you already picked a best answer. So encrypting the link is best in short terms.