如何使文件下载需要用户名和密码
在基本的 HTML 网页中,如何让用户必须输入用户名和密码才能下载文件?
在网站上(最好是纯 HTML)实现此目的的最佳方法是什么?
In a basic HTML web page, how do you make the user have to enter a username and password before they are allowed to download a file?
What is the best way of achieving this on a website, preferably in plain HTML?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这在 HTML 中无法实现。
使用客户端技术,您可能能够实现的最好效果是 JavaScript 提示,您可以使用其中的数据将人们引导至秘密 URI。
这确实应该由网络服务器处理 。
This can't be achieved in HTML.
With client side technologies, the best you are likely to be able to achieve is a JavaScript prompt that you use the data from to direct people to a secret URI.
This is something that really should be handled by the web server.
您将无法使用纯 HTML 来执行此操作。最简单的方法可能是将受保护的文件放在受 .htaccess 和 .htpasswd 文件保护的目录中。
You won't be able to do this with plain HTML. Easiest way is probably to place the protected file in a directory protected by an .htaccess and .htpasswd file.
我同意大卫的观点……这确实不可能完成。发出 JavaScript 提示只能保护您到目前为止......这并不真正安全。
如果您使用的是 Apache 服务器,则可以设置 .htaccess 文件并设置一些用户授权选项,这些选项指向包含下载文件链接的页面。一个简单的实现将为您提供 1 个用户/密码组合,您可以将其分发给您的用户。有关此内容的 Apache 文档可以在此处找到。不幸的是我不太熟悉 IIS 如何处理这类事情。
如果您不想向用户分发通用的用户名/密码组合,那么您几乎将不得不创建(或使用现有的)用户管理系统。网络上散布着相当多的模块,简单的 Google 搜索应该会给您带来相当多的教程或现有的实现,具体取决于您的需求。
I agree with David...this can't really be done. Putting up a JavaScript prompt only protects you so far as well...that isn't really secure.
If you are on an Apache server, you could setup a .htaccess file and setup some user authorization options that point at a page which has the link to your download file. A simple implementation would give you 1 user/password combo that you could distribute to your users. The Apache documentation for this may be found here. Unfortunately I'm not really familiar with how IIS handles this sort of thing.
If you don't want to distribute a generic username/password combo to your users, you're pretty much going to be stuck creating a (or making use of an exsitng) user-management system. There are quite a few modules strewn throughout the web, and a simple Google search should bring you to quite a number of tutorials or existing implementations, depending on what you require.
首先下载phpmyadmin。打开文件。单击创建登录。将其命名为login.php。然后创建一个新的名称为file.php。单击“是”后,它会弹出登录信息。输入您想要的用户名和密码
希望这有帮助!
first download phpmyadmin.open the file.click on create login.name it as login.php.then create a new want again name file.php.after you click yes it popout a logon information.enter the usrname you want and password you want
hope this help!