建设照片分享网站应采取的安全措施
我正在用 php 构建一个照片共享网站。我已经快完成了。我想知道我们在存储图像时应该采取哪些安全措施。我正在使用文件系统来存储图像。我怎样才能保证它的安全?我可以使用什么东西来密码保护存储图像的目录吗?
I am building a photo sharing website in php. I have almost completed it. I want to know what are the security measures we should take in storing images. I am using file system to store the images. How can I make it secure? Is there anything I can use to password protect the directories in which the images are stored?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最重要的是确保它不能被直接访问。文件应存储在 Web 根目录之外,并应使用脚本来发送图像。
这会增加开销,但会使其安全。利用 CDN 也会变得更加困难。
The biggest thing is to make sure it cannot be accessed directly. The files should be stored outside of the web root and a script should be used to send the image.
This adds overhead but it will make it secure. It will also be somewhat harder to take advantage of CDNs.
另一种可能的解决方案(无开销)包括使用 HTTP 基本访问身份验证来限制对图像文件夹的访问。您可以根据用户的凭据使用 PHP 维护 .htaccess 和密码文件。
如果您不希望浏览器弹出用户名和密码,您可以使用 JavaScript 提供它们。
Another possible solution - without overhead - consists in restricting the access to your image folder using HTTP basic access authentication. You can maintain the .htaccess and the password file with PHP accordingly with your user's credentials.
If you don't want the browser to popup for the user and password you can provide them using JavaScript.